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

Re: Is this a side effect of RC_EXPAND_PARAM?



On Dec 2, 10:04pm, DervishD wrote:
}
}     What am I doing wrong? Is this a bug or a feature?

zagzig% var="one|two||four|five"
zagzig% print -l "${(s:|:)var}"
one
two
four
five
zagzig% setopt rcexpandparam
zagzig% print -l "${(s:|:)var}"
one
two

four
five
zagzig% 

With rcexpandparam the empty element is retained so that it can be joined
with whatever appears on both sides of the expansion (even though in this
case that's nothing) so you get the equivalent of

    vara=("one" "two" "" "four" "five")

whereas with it NOT set, the empty element is removed, so you get

    vara=(one two  four five)

Forcing empty elements to be retained as empty rather than removed is
one reason the compsys functions have rcexpandparam set.  Admittedly
this ought to be documented, rather than assuming that anyone who sets
rcexpandparam must be familiar with the semantics of the rc shell ...



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