|
From: | Marco Ippolito |
Subject: | local -r for arrays |
Date: | Sun, 25 Oct 2020 18:42:17 +0000 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 |
I can do this: g1() { local -r a=2$1 echo "$a" } f1() { local -r a=1 g1 "$a" } f1 -> "21" but I can't do this: g2() { local -r a=(2 "$@") echo "${a[@]}" } f2() { local -r a=(1) g2 "${a[@]}" } f2 -> error "a: readonly variable" How does this "asymmetry" come about?
[Prev in Thread] | Current Thread | [Next in Thread] |