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

Re: ${^var} and word splitting



On Nov 24,  9:18pm, Stephane Chazelas wrote:
}
} I don't see the point in doing one and not the other. IOW in:
} 
} ~$ a=' a  b ' zsh -c 'print -l ${(s, ,)a}'
} a
} b
} ~$ a=' a  b ' zsh -c 'print -l "${(s, ,)a}"'
} 
} a
} b
} 
} ~$ a=' a  b ' zsh -c 'print -l "${(s, ,@)a}"'
} 
} a
} 
} b
} 
} ~$
} 
} I'd rather 2 above behave either like 1 or 2.

(Working with the presumption you mean "like 1 or 3".)

This may go back to a misinterpretation of documentation -- there are a
lot of little things about zsh that got that way because e.g. examples
in the ksh88 documentation were implemented without completely knowing
what was BNF-style markup and what was actual syntax.

Nevertheless I think the intention was that #2 is "collapse consecutive
whitespace to a single space and then act like #3".

In any case it all depends on where you apply the (@):

% a=' a  b ' zsh -c 'print -l "${(@)${(s, ,)a}}"'
a
b
% 


} It may be too late to change the behaviour now, though I'd find
} it hard to imagine people relying on "$=var" to make empty
} arguments at the beginning and end but not in the middle.

I have the nagging suspicion there may be cases in the completion code
that expect exactly that ... or that have been programmed to work around
it and would need to be fixed if it changes.

-- 
Barton E. Schaefer



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