Re: sh portability questions

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

 



* 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


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux