On Mon, Jun 29, 2009 at 07:10:29PM +0200, Cristian Ionescu-Idbohrn wrote:
>
> Please consider this example script:
> 
> ---8<---
> #!/bin/dash
> 
> set -e
> #set -x
> 
> func() {
>       local i=0 v xx="$@"
> 
>       for v; do
>               i=$(($i + 1))
>               echo "func arg. $i: '$v'"
>       done
>       echo "inside func: NOONE_SHOULD_TOUCH_THIS=$NOONE_SHOULD_TOUCH_THIS"
> }
> 
> NOONE_SHOULD_TOUCH_THIS=protected
> echo "main, bef. func: NOONE_SHOULD_TOUCH_THIS=$NOONE_SHOULD_TOUCH_THIS"
> func "$@"
> echo "main, aft. func: NOONE_SHOULD_TOUCH_THIS=$NOONE_SHOULD_TOUCH_THIS"
> 
> exit 0
> ---8<---
> 
> and run the script like this:
> 
>       $ <script path> abc NOONE_SHOULD_TOUCH_THIS=overwritten
> 
> Is it the intended behaviour?  Should one be able to overwrite script
> function variables from command line?

As I said, you should be using "$*" instead of "$@" which is
designed exactly for this purpose and is completely portable.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herb...@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to