Proposal for new cygwin.bat which is independent from install directory

Christian Franke
Sat Aug 27 13:13:00 GMT 2016

Bengt Larsson wrote:
> Andrey Repin wrote:
>>> The following should work since WinXP regardless of install directory:
>>> -----
>>> @echo off
>>> cd /d %~dp0
>>> if errorlevel 1 exit /b 1
>>> cd bin
>>> if errorlevel 1 exit /b 1
>>> bash --login -i
>>> -----
>> Why so complicated? 
> Also don't see why so complicated. While staying in the console, how
> about:
> -----
> @echo off
> cd /d "%~dp0\bin"
> bash --login -i
> -----

An errorlevel check is IMO mandatory after a cd command. Otherwise 
another bash in the PATH might be started if the directory does not exist.
Hmm... therefore it is also better to change the last line to:

   .\bash --login -i

The directory change is intentionally done with two cd commands to avoid 
possible problems with cmd variants (on Win10 "%~dp0" expands to a path 
with trailing backslash).


Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list