"which" command does not expand "~" in path

Errol Smith errol@ros.com.au
Sat Sep 25 18:31:00 GMT 2004


  If your PATH contains the tilde character (eg. "~/bin:.......") the 
cygwin version of "which" seems to fail to expand the "~" and will then not 
locate any commands in ~/bin (or any other directory on the path containing 
"~" presumably).

  I'm 99% sure it's cygwin's version of "which" causing the issue, because 
I compiled the GNU version and it works as expected (2.16 works out of the 
box with ./configure & make).
  (incidentally, the cygwin which.exe is about 5k and the gnu one is about 
80k!)

Testcase:
Uncomment the following section in ~/.bash_profile (from 
/etc/skel/.bash_profile)
....
Set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
   PATH="~/bin:${PATH}"
fi
....
Create a ~/bin then copy a command of some kind into it for testing (say 
"testprogram.exe"), then logout & log in again:

 > which testprogram
testprogram: Command not found.
 > whichgnu testprogram
/cygdrive/d/home/bin/testprogram

(whichgnu being the gnu version of "which" in this case)
I hope that was a simple enough example. I have reported this before (see 
http://www.cygwin.com/ml/cygwin/2004-05/msg00546.html ), but I'm trying 
harder this time :)

Regards, Errol


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



More information about the Cygwin mailing list