This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Sven Köhler wrote:
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.

Instead, the shell usually substitutes ~ or ~user.
Look at this the output of these commands:
    echo ~
    echo "~"

This is probably common knowledge, but I learned last night that sh never expands ~. Under sh, the two lines above yield the same output, simply ~.


So my conclusion was to never rely on ~ in scripts or variables.
(Unless something is broken in my setup?)

Cheers,
Rob


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]