Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Tue, 28 Sep 2004 13:14:54 -0400 (EDT) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com Subject: Re: "which" command does not expand "~" in path (base-files update needed) In-Reply-To: <20040928153144.GM26145@trixie.casa.cgf.cx> Message-ID: References: <6 DOT 1 DOT 2 DOT 0 DOT 1 DOT 20040929010527 DOT 027f4eb0 AT mail DOT ros DOT com DOT au> <20040928153144 DOT GM26145 AT trixie DOT casa DOT cgf DOT cx> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.39 On Tue, 28 Sep 2004, Christopher Faylor wrote: > On Wed, Sep 29, 2004 at 01:08:42AM +1000, Errol Smith wrote: > >At 09:23 PM 26/09/2004, "Hannu E K Nevalainen" wrote: > >>FWIW; 'man bash' has a section on Tilde Expansion - I take it as; bash does > >>this expansion for you, not which.exe -> use $HOME when not typing at the > >>prompt. > > > > This is all fine & good, but it doesn't change the fact that the > >cygwin-supplied "which" does NOT work with the cygwin-supplied > >".bash_profile" (when you use a personal ~/bin directory.). > > Here is a simple patch which fixes half the problem (the ".bash_profile" > >placing a raw ~ in the path): > > > >--- /etc/skel/.bash_profile 2004-05-15 21:40:04.000000000 +1000 > >+++ .bash_profile 2004-09-29 00:21:50.000000000 +1000 > >@@ -10,16 +10,16 @@ > > > > # Set PATH so it includes user's private bin if it exists > > # if [ -d ~/bin ] ; then > >-# PATH="~/bin:${PATH}" > >+# PATH="${HOME}/bin:${PATH}" > > # fi > > You can use ~ here. Just don't quote it. It shouldn't be quoted. > > export PATH=~/bin:"${PATH}" I'm sorry, but this isn't true, even for bash. It still leaves the "~" in the PATH, which confuses "which" (although "type", being a bash builtin, recognizes and expands it). The "~" is not expanded when used in a variable assignment (whether quoted or unquoted), even if 'echo' expands it. Oh, and your suggestion definitely won't work for sh, which also uses /etc/profile. IMO, any shell-specific code in /etc/profile should go into the shell-specific section of /etc/profile, and the rest of it should be Bourne shell compatible. > > # Set MANPATH so it includes users' private man if it exists > > # if [ -d ~/man ]; then > >-# MANPATH="~/man:${MANPATH}" > >+# MANPATH="${HOME}/man:${MANPATH}" > > # fi > > > > # Set INFOPATH so it includes users' private info if it exists > > # if [ -d ~/info ]; then > >-# INFOPATH="~/info:${INFOPATH}" > >+# INFOPATH="${HOME}/info:${INFOPATH}" > > # fi > > I don't know if man or info deal properly with ~ but neither of the > above should cause a problem for which. Neither man nor info does any ~-expansion, AFAICS. Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "Happiness lies in being privileged to work hard for long hours in doing whatever you think is worth doing." -- Dr. Jubal Harshaw -- 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/