delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/09/09/09:20:31

X-Recipient: archive-cygwin AT delorie DOT 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:date:from:reply-to:message-id:to:subject
:in-reply-to:references:mime-version:content-type
:content-transfer-encoding; q=dns; s=default; b=Fk8ifgI5O4ZGyr8t
d0Z3Ce6QJzv/wR7dK/5Jc05qGsgu3yfESg9/pAYHv2Wvgu9i8cR4EXncIg9toaTj
W8q03mkLjXvfOZ5KC3orsZxvzzNmdCiDnpVQH8hVjI2CbQN/kmlZFB5DnDTPrlqs
Abb1ddcakYJyMms2/wzZJ2KOj7Y=
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:date:from:reply-to:message-id:to:subject
:in-reply-to:references:mime-version:content-type
:content-transfer-encoding; s=default; bh=1Ks3N0b7QCq5wfi/b4u2rX
B7g/A=; b=usrOhbI+MoCNYoeC7vH42fibHMgarPgFt1+7XHxG5w/k42m6pWSPd2
mxEWNmOigMF59LS8Rssc8KJEREl4moKeHfxIFbAgzceYCANgabv7NfhI2vj2b/GM
UD+yaYnyxeMIML4quS4sSNSZGfR0tlwE5v5dEn/cN7aDi6iL+MhwQ=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=3.5 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KAM_THEBAT,SPF_SOFTFAIL autolearn=no version=3.3.2
X-HELO: smtpback.ht-systems.ru
Date: Tue, 9 Sep 2014 17:08:01 +0400
From: Andrey Repin <anrdaemon AT yandex DOT ru>
Reply-To: cygwin AT cygwin DOT com
Message-ID: <836662195.20140909170801@yandex.ru>
To: Gary Johnson <garyjohn AT spocom DOT com>, cygwin AT cygwin DOT com
Subject: Re: latest cygwin: 'run' problem
In-Reply-To: <20140909011413.GC4187@phoenix>
References: <87a96hrki4 DOT fsf AT Rainer DOT invalid> <54060378 DOT 2070108 AT gmail DOT com> <5406680D DOT 4030105 AT verizon DOT net> <540761FA DOT 1040902 AT verizon DOT net> <87ppfcqyc7 DOT fsf AT Rainer DOT invalid> <540A600A DOT 6090201 AT verizon DOT net> <540A6817 DOT 9080207 AT verizon DOT net> <20140906201229 DOT GA9220 AT phoenix> <20140908174606 DOT GA4187 AT phoenix> <1448944831 DOT 20140909024857 AT yandex DOT ru> <20140909011413 DOT GC4187 AT phoenix>
MIME-Version: 1.0
X-IsSubscribed: yes

Greetings, Gary Johnson!

>> @START "" /D "%~1" "%~dp0\mintty.exe"

>> > ------------------------- run_bash_here.sh -------------------------
>> > --------------------------------------------------------------------

>> This all is just not needed.
>> Just create a shortcut in "Sent to" to your bash-here.cmd - job done, reap the
>> rewards.

> Thanks very much for the example.  It took me a while to figure out
> what that does.

The key parts are in 'set /?' and 'call /?'.
'cmd /?' is also a good read.

> I copied that line to bash-here.cmd and created a
> shortcut to it from my SendTo directory.  It almost works, but there
> are a few things my version does that yours does not.

> First, yours works only if you execute it while the target directory
> is selected in its parent directory.  Mine also works to run mintty
> in the current directory if you execute it while a file in that
> directory is selected.

That makes little sense. Could be solved, though. CMD doesn't offer a
way to distinguish between file and directory, but we have test.

@ECHO OFF
SETLOCAL
SET CYGWIN=nodosfilewarning
"%~dp0\test.exe" -f "%~f1"
ENDLOCAL
IF ERRORLEVEL 1 (
  SET DEST=%~f1
) ELSE (
  SET DEST=%~dp1
)

START "" /D "%DEST%" "%~dp0\mintty.exe"

> Second, my version runs a login shell which sets up the environment
> correctly, e.g., puts /usr/local/bin:/usr/bin: at the head of PATH.

I already have environment correctly set at login. It's not like i'm logging
into random directories across my filesystem over and over again. I just start a shell where I need it.

> Just telling mintty to run a login shell isn't sufficient, however,
> because that also sets the current directory to your home directory,
> so you then need to cd to the target directory with the target path
> translated to Unix form.

That's why I don't start another login shell. It's inefficient. I already
logged it.

> Those issues may be easy to fix, but as I said, I don't know my way
> around cmd very well.

> It might actually be better if the script always started bash in the
> parent directory of the selected file.  That would be more
> consistent and could be simpler to implement.  I'll try to find an
> explanation of cmd parameter expansion and see what I can figure
> out.


--
WBR,
Andrey Repin (anrdaemon AT yandex DOT ru) 09.09.2014, <16:00>

Sorry for my terrible english...


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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019