Subject: Different behavior w/ and w/o local
To: None <tech-userlevel@netbsd.org>
From: Julio M. Merino Vidal <jmmv@menta.net>
List: tech-userlevel
Date: 09/14/2003 10:39:23
Hi all,
consider the following two shell functions:
f1() {
var=$1
echo $var
}
f2() {
local var=$1
echo $var
}
And the following calls with their respective output:
$ f1 "foo bar"
foo bar
$ f2 "foo bar"
foo
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?
Thanks.
--
Julio M. Merino Vidal <jmmv@menta.net>
The NetBSD Project - http://www.NetBSD.org/