This is the mail archive of the
mailing list for the Cygwin project.
Re: "which" command does not expand "~" in path
- From: Errol Smith <errol at ros dot com dot au>
- To: cygwin at cygwin dot com
- Date: Sun, 26 Sep 2004 11:25:04 +1000
- Subject: Re: "which" command does not expand "~" in path
- References: <email@example.com>
From: Sven Köhler
Subject: Re: "which" command does not expand "~" in path
Date: Sat, 25 Sep 2004 20:32:31 +0200
Set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
Hmm, i'm not 100% percent sure, but is this supposed to work in general? I
don't think that all programs that use the PATH varible are supposed to
interpret ~ correctly.
I don't know for certain (I am no expert), BUT I briefly examined source
code of both GNU "which" and cygwin "which" and the GNU version
specifically checks for "~" while the cygwin version does not. The cygwin
version essentially passes the partial PATH directly to a stat() function
call. I do not know if stat() is expected to interpret ~ as $HOME.
Instead, the shell usually substitutes ~ or ~user.
Look at this the output of these commands:
I'm fairly certain the shell is not expected to perform tilde expansion
if the tilde is quoted, so the difference between these two is expected.
I would suggest to use
PATH="$(echo -n ~)/bin:$PATH"
instead of your line.
The "PATH=.." line I quoted is from the _cygwin default .bash_profile_,
so if what you suggest is true, either way something in cygwin needs to be
modified (and yes, substituting $HOME for ~ does fix it, but that doesn't
stop someone manually putting ~ in their path). The which command on linux
works as expected, whether the path contains ~ or not.
I'm sure Corinna will know the correct behaviour - she's also the
maintainer of "which" ;-)
btw, I am using a fully updated cygwin with snapshot 20040924
btw2, if anyone knows how to get Eudora to let me reply to the digest and
have it thread properly in the archives, please let me know..
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html