Mail Archives: cygwin/2004/09/25/21:25:09
>From: Sven Köhler
>Subject: Re: "which" command does not expand "~" in path
>Date: Sat, 25 Sep 2004 20:32:31 +0200
>Message-ID: <cj4diq$1du$1 AT sea DOT gmane DOT org>
>
>>Set PATH so it includes user's private bin if it exists
>>if [ -d ~/bin ] ; then
>> PATH="~/bin:${PATH}"
>>fi
>
>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:
> echo ~
> echo "~"
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="$HOME/bin:$PATH"
>or even
> 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" ;-)
Regards, Errol
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
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -