Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Why local is needed?



Hi,

It seems that the variables used in a function by default are local
anyway. Does it mean that the command `local` is never necessary in a
function if the variables are specified as local variables? Thanks.

$ cat  ./main.sh
#!/usr/bin/env zsh
# vim: set noexpandtab tabstop=2:

set -v
function f {
	x=1
	y=(a b c)
}

declare -p x y
$   ./main.sh
function f {
	x=1
	y=(a b c)
}

declare -p x y
./main.sh:declare:10: no such variable: x
./main.sh:declare:10: no such variable: y

-- 
Regards,
Peng



Messages sorted by: Reverse Date, Date, Thread, Author