zsh-users
 help / 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

* Re: Why local is needed?
  2018-12-03  2:38 Why local is needed? Peng Yu
@ 2018-12-03  4:47 ` Eric Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Cook @ 2018-12-03  4:47 UTC (permalink / raw)
  To: zsh-users

you do know that you didn't run the function right?

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

end of thread, back to index

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

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox