delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/09/08/21:14:59

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:to:subject:message-id:references
:mime-version:content-type:in-reply-to; q=dns; s=default; b=q3yu
0AWlqS02qCrDs3wjZe37B7wPKsLIT3anTHYHvpBI+yJkReTRCjrsx0eogvNmEYvv
QgAwSfgagdi3lIvIfF6mmcM/3WXv9FYP9E7qD+ZRhYPPCb7g0QaSxSB0gd58Logm
DiFk6gzlTWsFDpUMQdhZy7zfD/LcCmD2wP570OA=
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:to:subject:message-id:references
:mime-version:content-type:in-reply-to; s=default; bh=G74Alia0kl
KWxcuOQ5l/lwc1Fmg=; b=yNMS29JjxR/JsHuYBPPc/d+gwvSJ4XDs4iuHGUf5E2
varmdVl3ccIt3h2epsvJbMqW0qp5WotI3AuD2mBa5wodx9w4Igt7zuU2oMUCwaSD
UaDtXGSfNuViCx09rgb0GUK9xfYZieCHV1IYhC4WdMGgzWp9Td849wFNuStMpP3r
g=
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=-2.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail.spocom.com
Date: Mon, 8 Sep 2014 18:14:13 -0700
From: Gary Johnson <garyjohn AT spocom DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: latest cygwin: 'run' problem
Message-ID: <20140909011413.GC4187@phoenix>
Mail-Followup-To: cygwin AT cygwin DOT com
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>
MIME-Version: 1.0
In-Reply-To: <1448944831.20140909024857@yandex.ru>
User-Agent: Mutt/1.5.20 (2009-06-14)
X-IsSubscribed: yes

On 2014-09-09, Andrey Repin wrote:
> Greetings, Gary Johnson!
> 
> > I wrote a batch file and a shell script to implement a Run Bash Here
> > feature from the Windows file manager "Send to" context menu, much
> > like chere but without having to mess with the registry.  The
> > hardest part was getting the quoting in the run command line right
> > so that both cmd and bash were happy.  The files are included
> > in-line below.
> 
> That's overengineered.

Perhaps.  I know very little about Windows cmd shell programming, so
I tried to pass the file name to bash early in the process and
perform any logic there.

> > ------------------------ run_bash_here.bat -------------------------
> > --------------------------------------------------------------------
> 
> Replace it all with this "bash-here.cmd" placed in /bin :
> 
> @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.  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.

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

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.

Regards,
Gary


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