From 2a4d208b96521bce587b6d181617983392225715 Mon Sep 17 00:00:00 2001 From: ph4nt0m Date: Tue, 3 May 2016 09:18:56 +0200 Subject: [PATCH] filesystem: Add -where parameter to start_shell.cmd * Introduce parameter '-where' which must be followed by an existing directory which will be used to start the shell in (use . for the current working directory) * Use setlocal to return to the original directory after this script finished (any calls to cd will be local to this script) --- filesystem/start_shell.cmd | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/filesystem/start_shell.cmd b/filesystem/start_shell.cmd index e0a9d894..b5c2f64a 100644 --- a/filesystem/start_shell.cmd +++ b/filesystem/start_shell.cmd @@ -1,4 +1,5 @@ @echo off +setlocal set "WD=%__CD__%" if NOT EXIST "%WD%msys-2.0.dll" set "WD=%~dp0usr\bin\" @@ -29,6 +30,15 @@ if "x%~1" == "x-conemu" shift& set MSYSCON=conemu& goto :checkparams if "x%~1" == "x-defterm" shift& set MSYSCON=defterm& goto :checkparams rem Other parameters if "x%~1" == "x-use-full-path" shift& set MSYS2_PATH_TYPE=inherit& goto :checkparams +if "x%~1" == "x-where" shift& ( + set CHERE_INVOKING=1 + rem Check if next argument is an existing directory + if not "%~2" == "" if exist "%~2\" shift& cd /d "%~2\"& goto :checkparams + + rem If not, print error and exit + echo Invalid directory specified for -where. Exiting. 1>&2 + exit /b 1 +) rem Autodetect shell type if not specified