delorie.com/archives/browse.cgi | search |
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:from:to:subject:references:date:in-reply-to | |
:message-id:mime-version:content-type; q=dns; s=default; b=ltyVg | |
SyoIO967Ly0REIEXOe1Ft5NXqoJXCfr5n/20A35cgzD7T212EXO4TXb8yUZucMDZ | |
Md1QJwHIZiqnYtHbVLv9IP6tUTTFt+JUqg79A3OdeeOzJeZxoj9THunIMEbqn8QG | |
ylBGmCI3Py5lVMjBDWRrFNn7/KVxXWj7Yv9MtI= | |
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:from:to:subject:references:date:in-reply-to | |
:message-id:mime-version:content-type; s=default; bh=nepovKbxXlS | |
GbpFbAA74rDR86WA=; b=xBzbm9RW0uLxdo+bxdjpZqZ5f5riVZCg0LLt3SzUsH2 | |
UKBUCeZBXIskIjaj0td1QA6ujZeXzeNLaZx9XeI3i6Hakf6dfUZ4lu15R/WODoeZ | |
Qp5N98gG9kkpNwrbSg/Bk7QrqmClCfuUv2w+pI9IiomwTP1mlArGVh7f0L1Drkos | |
= | |
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=-5.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 |
X-HELO: | mail-in-06.arcor-online.net |
X-DKIM: | Sendmail DKIM Filter v2.8.2 mail-in-14.arcor-online.net 728E69BE21 |
From: | Achim Gratz <Stromeko AT nexgo DOT de> |
To: | cygwin AT cygwin DOT com |
Subject: | Re: latest cygwin: 'run' problem |
References: | <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> <20140909030238 DOT GD4187 AT phoenix> |
Date: | Tue, 09 Sep 2014 11:15:03 +0200 |
In-Reply-To: | <20140909030238.GD4187@phoenix> (Gary Johnson's message of "Mon, 8 Sep 2014 20:02:38 -0700") |
Message-ID: | <87oaup6tpk.fsf@Rainer.invalid> |
User-Agent: | Gnus/5.13 (Gnus v5.13) Emacs/24.3.93 (gnu/linux) |
MIME-Version: | 1.0 |
Gary Johnson writes: > After much fiddling (programming by successive approximation), You should drop the cargo-cult programming before it hurts you. > I came up with this: > > @START "" "C:\cygwin\bin\mintty.exe" /bin/bash --login -c "cd $(cygpath -u $0); exec bash -i" "%~p1\" You want at least %~dp1 there (in an CMD window, type HELP CALL). But you can start mintty directly from the shortcut without any intervention of START or run and you don't need a batch file or shell script either. Things get a lot simpler if you cut out the intermediaries, although you still need to be careful. If you go through CMD or a shell script, there are more levels of quoting involved and more processes to start. Doing this through both a CMD and a shell script is seriously overcomplicated and keeping track of what needs to go where is much more difficult to figure out, so just don't do it. > Using an explicit path to mintty lets me put the script itself > someplace other than /bin. > > Because %~p1 ends with a backslash, I had to add another backslash > before the closing quote to prevent the quote from being included in > the path. (See http://ss64.com/nt/syntax-args.html and > http://ss64.com/nt/syntax-esc.html#escape.) > > I haven't tried it yet with a path that includes a space. Tomorrow. It won't work because you did not quote the result from cygpath. If you want to get this right, you should work it out from the inside. You want the cd command to get a directory name from a subcommand that may contain spaces, so you need to quote the result: cd "$( ... )" Since the argument you're getting may actually be a filename, you need to use the dirname command and quote its argument again: cd "$(/bin/dirname "$(...)")" and dirname gets its argument from cygpath, and the argument to cygpath must itself be quoted again: cd "$("$(/bin/dirname "$(/bin/cygpath -u "$1")")")" If that suceeds you want to replace the current interpreter with an interactive bash: cd "$("$(/bin/dirname "$(/bin/cygpath -u "$1")")")" && exec /bin/bash -i That is in entirety the command that you need to give to the "-c" option of the outer bash invocation as a single argument. The remaining arguments are filled in from $0 and since I specified $1 to cygpath, there's a dummy parameter to be placed, let's call it "BashHere". So that outer bash needs to get started like this: /bin/bash -lc cmd_argument BashHere dir_argument Since you're actually starting it from a shortcut, you need to keep in mind that the quoting rules for the shortcut target are those of the MS CRT, which means you need to wrap single arguments containing whitespace in double quotes and then backslash escape any double quotes (and backslashes, of which we don't have any) inside those arguments. This will then be put into argv from mintty, which will exec bash with those arguments it didn't consume itself, which means there needs to be no extra level of quoting. So that shortcut target becomes (undo the linewrap): C:\Freeware\Cygwin\bin\mintty.exe -e "cd \"$(\"$(/bin/dirname \"$(/bin/cygpath -u \"$1\")\")\")\" && exec /bin/bash -i" BashHere The dir_argument gets filled in as the last argument by the drag&drop or SendTo operation. Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Factory and User Sound Singles for Waldorf Blofeld: http://Synth.Stromeko.net/Downloads.html#WaldorfSounds -- 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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |