zsh-users
 help / color / mirror / code / Atom feed
* Why local is needed?
@ 2018-12-03  2:38 Peng Yu
  2018-12-03  4:47 ` Eric Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Peng Yu @ 2018-12-03  2:38 UTC (permalink / raw)
  To: zsh-users

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-03  5:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-03  2:38 Why local is needed? Peng Yu
2018-12-03  4:47 ` Eric Cook

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).