[PATCH] Remove . from $PATH
Johannes Stezenbach
js@sig21.net
Thu Jul 29 18:07:00 GMT 2010
On Thu, Jul 29, 2010 at 07:21:49PM +0200, Yann E. MORIN wrote:
> On Thursday 29 July 2010 17:19:16 Johannes Stezenbach wrote:
> > Remove . from $PATH
> [--SNIP--]
> > + for p in $PATH; do
> > + tmp=`(cd /tmp; cd $p 2>/dev/null || :; pwd -P)`
>
> No need to enclose it in a sub-shell. Also, the rest of the code
> does not use `blah`, but uses $(blah).
>
> The ':' is absolutely valid, but a bit non-trivial. I prefer to be
> really explicit and call 'true'.
>
> So I'm changing that line to:
> tmp="$( cd /tmp; cd "${p}" 2>/dev/null || true; pwd -P )"
>
> > + if [ "$tmp" != "/tmp" ]; then
>
> Using /tmp as a default if the path is not found is a bit hacky! :-P
> And replacing '.' with $(pwd) is no-less hacky! That's a clever way
> to test everything in a single go! :-)
Yeah, I have to admit it's a bit over-engineered, but my goal
was to catch paths like "./" or "bin" (intead of "~/bin") etc.
Of course one could argue that people who have gunk in their PATH
shoot themselves in the foot and deserve it, however they
might then send a useless bug report.
Thanks,
Johannes
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list