From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cristian Ionescu-Idbohrn Subject: Re: Parameter expansion fails when assigning a local variable Date: Tue, 30 Jun 2009 18:17:50 +0200 (CEST) Message-ID: <0906301817190.14361@somehost> References: <20090622085729.GA22431@gondor.apana.org.au> <0906282220250.1491@somehost> <20090629004750.GA2019@gondor.apana.org.au> <0906291823520.16266@somehost> <20090630013807.GA13339@gondor.apana.org.au> Reply-To: Cristian Ionescu-Idbohrn Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Return-path: Received: from [193.13.178.8] ([193.13.178.8]:39273 "EHLO miranda.se.axis.com" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754824AbZF3QSY (ORCPT ); Tue, 30 Jun 2009 12:18:24 -0400 In-Reply-To: <20090630013807.GA13339@gondor.apana.org.au> Sender: dash-owner@vger.kernel.org List-Id: dash@vger.kernel.org To: Herbert Xu Cc: Jesper Bengtsson , dash@vger.kernel.org On Tue, 30 Jun 2009, Herbert Xu wrote: > 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: > > > > $