This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Am 27.08.2016 um 13:24 schrieb Christian Franke:
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).
If someone submits a patch to change cygwin.bat, please also add a command to clear $TERM on that occasion, in order to avoid trouble if cygwin.bat is started from a terminal:
set TERM=

Thomas

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]