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 From: "Dave Korn" To: Subject: RE: "which" command does not expand "~" in path (base-files update needed) Date: Tue, 28 Sep 2004 18:34:50 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit In-Reply-To: Message-ID: X-OriginalArrivalTime: 28 Sep 2004 17:36:35.0939 (UTC) FILETIME=[B3D0DB30:01C4A581] > -----Original Message----- > From: cygwin-owner On Behalf Of Igor Pechtchanski > Sent: 28 September 2004 18:15 > > 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). Why isn't it expanded by bash's tilde substitution at the time the 'export' command line is parsed then? That's sooo wrong. Oh wow. Guess what: it depends whether the *other* part of the assignment is quoted or not: dk AT mace ~> echo ${PATH} /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/win/c/WINDOWS/system32:/win/c/WINDO WS:/win/c/WINDOWS/System32/Wbem dk AT mace ~> export FOO=~/bin:"${PATH}" dk AT mace ~> echo "${FOO}" ~/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/win/c/WINDOWS/system32:/win/c /WINDOWS:/win/c/WINDOWS/System32/Wbem dk AT mace ~> echo ${FOO} ~/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/win/c/WINDOWS/system32:/win/c /WINDOWS:/win/c/WINDOWS/System32/Wbem dk AT mace ~> echo $FOO ~/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/win/c/WINDOWS/system32:/win/c /WINDOWS:/win/c/WINDOWS/System32/Wbem dk AT mace ~> export FOO=~/bin:${PATH} dk AT mace ~> echo "${FOO}" /home/dk/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/win/c/WINDOWS/system32 :/win/c/WINDOWS:/win/c/WINDOWS/System32/Wbem dk AT mace ~> echo ${FOO} /home/dk/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/win/c/WINDOWS/system32 :/win/c/WINDOWS:/win/c/WINDOWS/System32/Wbem dk AT mace ~> echo $FOO /home/dk/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/win/c/WINDOWS/system32 :/win/c/WINDOWS:/win/c/WINDOWS/System32/Wbem dk AT mace ~> < The "~" is not expanded when used in a > variable assignment (whether quoted or unquoted), even if > 'echo' expands it. I disagree. The ~ is not expanded when quotation is used, even if the ~ itself is not quoted. The expansion seems not to be being performed by echo. >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. Given that we don't care about the home dir of any but the currently-logged in user, there's no need to go to such lengths of grepping /etc/passwd: wouldn't the most generic, cross platform thing to be to take advantage of the behaviour of cd ? dk AT mace ~> echo "${FOO}" /home/dk/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/win/c/WINDOWS/system32 :/win/c/WINDOWS:/win/c/WINDOWS/System32/Wbem dk AT mace ~> echo ${FOO} /home/dk/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/win/c/WINDOWS/system32 :/win/c/WINDOWS:/win/c/WINDOWS/System32/Wbem dk AT mace ~> echo $FOO /home/dk/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/win/c/WINDOWS/system32 :/win/c/WINDOWS:/win/c/WINDOWS/System32/Wbem dk AT mace ~> cheers, DaveK -- Can't think of a witty .sigline today.... -- 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/