This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: latest cygwin: 'run' problem
- From: Andrey Repin <anrdaemon at yandex dot ru>
- To: Gary Johnson <garyjohn at spocom dot com>, cygwin at cygwin dot com
- Date: Tue, 9 Sep 2014 17:08:01 +0400
- Subject: Re: latest cygwin: 'run' problem
- Authentication-results: sourceware.org; auth=none
- 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>
- Reply-to: cygwin at cygwin dot com
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@yandex.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