mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-12-28 16:15:02 +01:00
Test typeset preserves types of existing variables when already local
This commit is contained in:
parent
7529c2a158
commit
4a63170c2c
1 changed files with 45 additions and 1 deletions
|
@ -595,7 +595,7 @@
|
||||||
enable -r typeset
|
enable -r typeset
|
||||||
disable typeset
|
disable typeset
|
||||||
print reserved
|
print reserved
|
||||||
eval $fn;fn
|
eval $fn; fn
|
||||||
)
|
)
|
||||||
0:reserved word and builtin interfaces
|
0:reserved word and builtin interfaces
|
||||||
>reserved
|
>reserved
|
||||||
|
@ -607,3 +607,47 @@
|
||||||
>reserved
|
>reserved
|
||||||
>one word=two
|
>one word=two
|
||||||
>
|
>
|
||||||
|
|
||||||
|
fn() {
|
||||||
|
emulate -L zsh
|
||||||
|
setopt typeset_silent
|
||||||
|
local k
|
||||||
|
typeset -A hash=(k1 v1 k2 v2)
|
||||||
|
typeset foo=word array=(more than one word)
|
||||||
|
for k in ${(ko)hash}; do
|
||||||
|
print $k $hash[$k]
|
||||||
|
done
|
||||||
|
print -l $foo $array
|
||||||
|
typeset -A hash
|
||||||
|
typeset foo array
|
||||||
|
for k in ${(ko)hash}; do
|
||||||
|
print $k $hash[$k]
|
||||||
|
done
|
||||||
|
print -l $foo $array
|
||||||
|
typeset hash=(k3 v3 k4 v4) array=(odd number here)
|
||||||
|
for k in ${(ko)hash}; do
|
||||||
|
print $k $hash[$k]
|
||||||
|
done
|
||||||
|
print -l $array
|
||||||
|
}
|
||||||
|
fn
|
||||||
|
0:typeset preserves existing variable types
|
||||||
|
>k1 v1
|
||||||
|
>k2 v2
|
||||||
|
>word
|
||||||
|
>more
|
||||||
|
>than
|
||||||
|
>one
|
||||||
|
>word
|
||||||
|
>k1 v1
|
||||||
|
>k2 v2
|
||||||
|
>word
|
||||||
|
>more
|
||||||
|
>than
|
||||||
|
>one
|
||||||
|
>word
|
||||||
|
>k3 v3
|
||||||
|
>k4 v4
|
||||||
|
>odd
|
||||||
|
>number
|
||||||
|
>here
|
||||||
|
|
Loading…
Reference in a new issue