This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi, On Fri, Jul 30, 2010 at 6:35 AM, Johannes Stezenbach <js@sig21.net> wrote: > On Thu, Jul 29, 2010 at 09:29:37PM -0400, Arnaud Lacombe wrote: >> On Thu, Jul 29, 2010 at 11:19 AM, Johannes Stezenbach <js@sig21.net> wrote: >> > + ? ?local IFS=: >> > + ? ?for p in $PATH; do >> > + ? ? ? ?tmp=`(cd /tmp; cd $p 2>/dev/null || :; pwd -P)` >> this is broken... If you refer to POSIX description of PATH (see [0]), >> "::" stands as synonym for ":.:" which is translated to the current >> directory. In your script, you will end up in doing a chdir to the >> HOME directory (if "set to a non-empty value") and still accepting the >> (empty) value. > > Ouch. ?Thanks for pointing this out. > >> Why not only accepting absolute directory or directory starting with "~": >> >> test -n "${var}" -a -z "${var%%[~/]*}" && new=... >> >> should do the job. > > I agree this is more straight forward. ?I like it. > (However I wonder if ~ is valid in PATH? I think the shell will > expand ~ when you set PATH, but execvp() would not?) > I just tested, sh will not do any expansion (even when the variable is set), and the lookup will fail, so "~" in PATH is not valid. It can be removed from the test :) - Arnaud -- For unsubscribe information see http://sourceware.org/lists.html#faq
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |