mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-12-29 16:25:35 +01:00
Some more typeset tests and fix for nested asignment
This commit is contained in:
parent
a2229ce10c
commit
7529c2a158
2 changed files with 90 additions and 0 deletions
|
@ -1898,10 +1898,18 @@ par_simple(int *cmplx, int nr)
|
|||
parr = ecadd(0);
|
||||
ecstr(tokstr);
|
||||
cmdpush(CS_ARRAY);
|
||||
/*
|
||||
* Careful here: this must be the typeset case,
|
||||
* but we need to tell the lexer not to look
|
||||
* for assignments until we've finished the
|
||||
* present one.
|
||||
*/
|
||||
intypeset = 0;
|
||||
zshlex();
|
||||
n = par_nl_wordlist();
|
||||
ecbuf[parr] = WCB_ASSIGN(WC_ASSIGN_ARRAY, WC_ASSIGN_NEW, n);
|
||||
cmdpop();
|
||||
intypeset = 1;
|
||||
if (tok != OUTPAR)
|
||||
YYERROR(oecused);
|
||||
zshlex();
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
%prep
|
||||
|
||||
mkdir typeset.tmp && cd typeset.tmp
|
||||
|
||||
setopt noglob
|
||||
|
||||
scalar=scalar
|
||||
|
@ -517,6 +519,7 @@
|
|||
print -l $one $two $three $four $five
|
||||
}
|
||||
fn
|
||||
print -l $one $two $three $four $five
|
||||
0:typeset reserved word interface: basic
|
||||
> eins
|
||||
>zwei
|
||||
|
@ -525,3 +528,82 @@
|
|||
> vier
|
||||
>cinq
|
||||
>cinque
|
||||
>hidden
|
||||
>hidden
|
||||
>hidden
|
||||
>hidden
|
||||
>hidden
|
||||
|
||||
(
|
||||
setopt glob
|
||||
mkdir -p arrayglob
|
||||
touch arrayglob/{one,two,three,four,five,six,seven}
|
||||
fn() {
|
||||
typeset array=(arrayglob/[tf]*)
|
||||
print -l ${array:t}
|
||||
#
|
||||
typeset {first,second,third}=the_same_value array=(
|
||||
extends
|
||||
over
|
||||
multiple
|
||||
lines
|
||||
)
|
||||
print -l $first $second $third "$array"
|
||||
#
|
||||
integer i=$(echo 1 + 2 + 3 + 4)
|
||||
print $i
|
||||
#
|
||||
# only noted by accident this was broken..
|
||||
# we need to turn off special recognition
|
||||
# of assignments within assignments...
|
||||
typeset careful=( i=1 j=2 k=3 )
|
||||
print -l $careful
|
||||
}
|
||||
fn
|
||||
)
|
||||
0:typeset reserved word, more complicated cases
|
||||
>five
|
||||
>four
|
||||
>three
|
||||
>two
|
||||
>the_same_value
|
||||
>the_same_value
|
||||
>the_same_value
|
||||
>extends over multiple lines
|
||||
>10
|
||||
>i=1
|
||||
>j=2
|
||||
>k=3
|
||||
|
||||
(
|
||||
# reserved word is recognised at parsing.
|
||||
# yes, this is documented.
|
||||
# anyway, that means we need to
|
||||
# re-eval the function...
|
||||
fn='
|
||||
fn() {
|
||||
typeset foo=`echo one word=two`
|
||||
print $foo
|
||||
print $word
|
||||
}
|
||||
'
|
||||
print reserved
|
||||
eval $fn; fn
|
||||
print builtin
|
||||
disable -r typeset
|
||||
eval $fn; fn
|
||||
enable -r typeset
|
||||
disable typeset
|
||||
print reserved
|
||||
eval $fn;fn
|
||||
)
|
||||
0:reserved word and builtin interfaces
|
||||
>reserved
|
||||
>one word=two
|
||||
>
|
||||
>builtin
|
||||
>one
|
||||
>two
|
||||
>reserved
|
||||
>one word=two
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue