Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Why local is needed?
- X-seq: zsh-users 23780
- From: Peng Yu <pengyu.ut@xxxxxxxxx>
- To: zsh-users <zsh-users@xxxxxxx>
- Subject: Why local is needed?
- Date: Sun, 2 Dec 2018 20:38:44 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=3/RseflqQv3mVlpT6DCa5VPRq4YcE8pd9GmbdJ3HD8s=; b=Msu7Px92sQwPdJuojP5w9JjEHqIAZndCupNYdlBNQbyi1cezPSlf5PwcZqaeJFwlan wnC/MLnKxWMK8b6P7hW0Yzll4m8wHnyNVeTXgoCWDR//Cbd2sfln0UVRf2b7OFOpUUU0 YBmV+j6JjJCXyFdVMVp05gTDiI5TECssI9H0YQPgoy0w/m3UZwNUpT4Qt8iQF3zrJj6A CJn2liXmzdK5sTLTNUoqmTDwuwzTUuXb2q90HKTewRo9C8/rVvN2bFqycx/w+6KbOkaj i56g8SqFkED2AxBKRQWsShSFKaa6Sx0Mugzjl+iHS5Bmdstw9wqZ5nkHh6XodbvbERJN 9DRA==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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