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]

Re: [PATCH] Remove . from $PATH


Johannes, All,

On Thursday 29 July 2010 17:19:16 Johannes Stezenbach wrote:
> Remove . from $PATH
[--SNIP--]
> diff -r c5a2e4ee7fb8 scripts/functions
> --- a/scripts/functions	Mon Jul 26 00:07:17 2010 +0200
> +++ b/scripts/functions	Thu Jul 29 15:34:42 2010 +0200
> @@ -137,6 +137,22 @@
>      CT_DoLog ${level:-INFO} "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})"
>  }
>  
> +# Remove entries referring to ., /tmp and non-existing directories from $PATH
> +# Usage: CT_SanitizePath
> +CT_SanitizePath() {
> +    local new
> +    local tmp
> +    local IFS=:
> +    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! :-)

I'll add that as a morecomplete explanation.

> +            new="$new${new:+:}$p"
> +        fi
> +    done
> +    PATH="$new"
> +    return 0
> +}
> +
>  # Abort the execution with an error message
>  # Usage: CT_Abort <message>
>  CT_Abort() {

Thank you!

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'



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