Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

unexpected clearing of parameter flags with ::=



% typeset -Z3 i
% echo ${i=5}
005
% echo ${i:=15}
005
% echo ${i::=15}
15

The manpage says
 ${name::=word}
  In the first form, if name is unset then set it to word; in the second
  form, if name is unset or null then set it to word; and in  the  third
  form,  unconditionally  set  name to word.  In all forms, the value of
  the parameter is then substituted.

which to me doesn't imply that the parameter is reset first,
especially since it isn't reset for the first form. I'm a little
confused as to why this doesn't assign the value either:

% unset i
% typeset -Z3 i
% echo ${i:=25}

but this does set it:
% unset i
% typeset i
% echo ${i:=25}
25

I thought maybe -Z3 causes the implicit value to be 000 but it is
printed as empty, so shouldn't it fulfil the "unset or null" condition
despite the -Z flag being active?

-- 
Mikael Magnusson




Messages sorted by: Reverse Date, Date, Thread, Author