X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:subject:to:references:from:message-id:date
	:mime-version:in-reply-to:content-type
	:content-transfer-encoding; q=dns; s=default; b=M1YfdmGYUdKjfF+8
	DRk92KnP1dzMeAeV8rqlagNgt/yBaokvf5vOXe9yPVIivXiu+TTInUyu8RY+CU7C
	h8o/UOWE6miozAtXprFShLBAo9QRI6F+YCdlGfPaj2A7Jx/T3NT3HHzPBq766+bD
	RJn+7KPSIuajCu7PpYh8C6AgO9I=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:subject:to:references:from:message-id:date
	:mime-version:in-reply-to:content-type
	:content-transfer-encoding; s=default; bh=pPI4xXj19xSMaPBBV7XGxh
	9ge0A=; b=rT01pRQQa5HOTVhzLzWNchFXD1uQVimDZVHHuU/HurRoRw802iGX+g
	XbfnIUYBOWN8ByN96ygRNnYo5KvhSoH1SlAIEQceuVmzLiuVocDUtoe4vg61EnL2
	1fbWT9td6M/lQ/ZpLgnLO9osgkuGbzu6nguVqFn4X5DQqKkvZ2ml0=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=1.6 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=HX-Envelope-From:sk:Christi, larsson, bengt, Larsson
X-HELO: mailout12.t-online.de
Subject: Re: Proposal for new cygwin.bat which is independent from install directory
To: cygwin@cygwin.com
References: <57C06CFA.4060405@t-online.de> <1974732522.20160826193931@yandex.ru> <daq2sb15dt33v54ekoc1p8f4snvepa0og0@4ax.com>
From: Christian Franke <Christian.Franke@t-online.de>
Message-ID: <57C1788B.2010705@t-online.de>
Date: Sat, 27 Aug 2016 13:24:59 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0 SeaMonkey/2.40
MIME-Version: 1.0
In-Reply-To: <daq2sb15dt33v54ekoc1p8f4snvepa0og0@4ax.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-IsSubscribed: yes

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


Christian


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

