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

Andrey Repin
Sat Aug 27 16:35:00 GMT 2016

Greetings, Christian Franke!

>> 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.

Absolutely unnecessary.
--login will change the CWD either way, and if it fail to execute, it will
fail either way.
Do NOT include redundant error handling "just because you can", or to report
to the user.
Only include error handling, if you have a plan to recover from error
condition, otherwise the scripting engine will report the error on its own,
you don't need to do anything special for that.

> Otherwise
> another bash in the PATH might be started if the directory does not exist.

That's because you're doing it wrong.

> Hmm... therefore it is also better to change the last line to:

>    .\bash --login -i

"%~dp0bin\bash.exe" --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).

It ALWAYS expands into a path with trailing slash.
Read CALL /? and note the combining rules for modifiers.

With best regards,
Andrey Repin
Saturday, August 27, 2016 19:05:19

Sorry for my terrible english...

Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list