Subject: Re: Different behavior w/ and w/o local
To: Jachym Holecek <>
From: Jachym Holecek <>
List: tech-userlevel
Date: 09/14/2003 11:55:32
> > Is this different behavior expected?  I've seen this happens with both /bin/sh
> > and /bin/ksh, though there is no mention to this in manpages, afaict.
> > Or should I be quoting assignments, like var="$1", to avoid problems?
> When I try
> f2() {
> 	local var
> 	var=$1
> 	echo $var
> }
> it works as expected (/bin/sh on 1.6.1). So it looks like a bug (either
> in code or in manpage not documenting it).

After waking up a bit: in

	local var=$1

the '$1' is expanded first, then the 'local' command is processed. For
$1="foo bar" it really sees 'local var=foor bar' (try local var=$1="hello"
and then echo $bar. Surprise :)). Looking at the manpage again, I should
correct myself, as it says

	local [variable | -] ...

so an assigment is probably not expected here. So it does not look like
a bug after all (and sorry for chaotic post).

 		-- Jachym Holecek