libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sh portability questions


From: Ralf Wildenhues
Subject: Re: sh portability questions
Date: Wed, 28 Sep 2005 16:27:25 +0200
User-agent: Mutt/1.5.11

* Akim Demaille wrote on Wed, Sep 28, 2005 at 01:36:11PM CEST:
> 
> Thanks, I didn't know.  How about this then?

> (
>     foo=bar
>     test_local () {
>         local foo=foo
>     }
>     test_local
>     test $foo = bar
> ) || local () {
>     case $1 in
>         *=*) eval "$1";;
>     esac
> 
> }

That does not test what you'd like to know (if local doesn't work in
test_local, foo won't be reassigned), and the logic is wrong.

I believ you can even fail if you know you can't handle the assignment
(and you also don't want to see the test failure):

(
    test_local () {
        #set -x
        local lfoo=foo 2>/dev/null
        foo=$lfoo
    }
    test_local
    test -n "$foo"
) || local () {
    case $1 in
        *[$IFS]*)
             echo "local assignments with white space not implemented" >&2
             exit 1;;
        *=*) eval "$1";;
    esac
}

Tested with Solaris 9 sh and dtksh (the latter does not have `local').
But why not allow `local a=b c=d'?

Cheers,
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]