[PATCH] Remove . from $PATH

Johannes Stezenbach js@sig21.net
Fri Jul 30 10:35:00 GMT 2010


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?)


Thanks
Johannes

--
For unsubscribe information see http://sourceware.org/lists.html#faq



More information about the crossgcc mailing list