delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/25/21:25:09

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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
Message-Id: <6.1.2.0.1.20040926105406.02d8bc70@mail.ros.com.au>
X-Sender: errol AT mail DOT ros DOT com DOT au (Unverified)
Date: Sun, 26 Sep 2004 11:25:04 +1000
To: cygwin AT cygwin DOT com
From: Errol Smith <errol AT ros DOT com DOT au>
Subject: Re: "which" command does not expand "~" in path
In-Reply-To: <1096159940.21953.ezmlm@cygwin.com>
References: <1096159940 DOT 21953 DOT ezmlm AT cygwin DOT com>
Mime-Version: 1.0
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id i8Q1P8mQ010387

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


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019