Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
${...:-...} again and subst clarification E: PATCH: param stuff and was: PATCH: 3.1.5-pws-12: _brace_parameter
- X-seq: zsh-workers 5935
- From: "Andrej Borsenkow" <borsenkow.msk@xxxxxx>
- To: "Sven Wischnowsky" <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>, <zsh-workers@xxxxxxxxxxxxxx>
- Subject: ${...:-...} again and subst clarification E: PATCH: param stuff and was: PATCH: 3.1.5-pws-12: _brace_parameter
- Date: Thu, 25 Mar 1999 15:00:06 +0300
- Importance: Normal
- In-reply-to: <199903161150.MAA25602@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
> > >
> > > 1) let it treat the `bar' always as a string (i.e. let it never be
> > > split into array elements); I guess this is what most people
> > > would expect (and in the manual the thing is called `word')
> >
I just found, that ${...:-...} does not work with arrays at all
bor@itsrm2:~%> foo=()
bor@itsrm2:~%> bar=(c d)
bor@itsrm2:~%> args ${foo:-${bar}}
0
bor@itsrm2:~%> args ${foo-${bar}}
0
If this was intended, then this change is really O.K and does the right
thing. But then, it should explicitly be mentioned in manuals.
The same applies to words after %, #, /, = (without (A)) and to val in
FOO=val as well. In all these contexts array value is forced (joined) to
scalar. May be, it is needed to be explicitly stated as well (to avoid
confusion). ${...=...} case is mentioned - but, probably, it would be better
to have them explained in rules in the correct place - even more so, as the
way it is done is again inconsistent:
bor@itsrm2:~%> setopt shwordsplit
bor@itsrm2:~%> IFS="$IFS:"
bor@itsrm2:~%> foo=("x:y" "a:b")
bor@itsrm2:~%> bar=$foo
bor@itsrm2:~%> print "$bar"
x:y a:b
No word splitting. The same applies to #, % and /.
bor@itsrm2:~%> yyy=${xxx:-$foo}
bor@itsrm2:~%> print "$yyy"
x y a b
$foo is wordsplitted. the same with =.
cheers
/andrej
Messages sorted by:
Reverse Date,
Date,
Thread,
Author