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

Re: Counting characters in command output?





On 2024-02-13 22:49, Roman Perepelitsa wrote:
Right, command substitution. In my opinion, it's unfortunate that
command substitution in zsh splits on IFS by default. I wish this
wasn't the case. It's not even common that one wants to split command
output into words. Lines -- perhaps, but not words. So the default
behavior in this case is rarely what is desired and has to be actively
turned off.
What are the vectors?  First must be logical necessity, second consistency -- avoid strange exceptions -- third and fourth would be helpfulness and tradition, with old-school guys favoring tradition and guys like me favoring helpfulness.  I've spent more hours trying to get splitting issues correct than anything else.  Characters, words, IFS, lines, elements ... it's the  most obscure and confusing part of the shell.  Lacking any focused explanation of the entire subject what I do is just throw saved snippets of code at problems until something sticks -- it looks about right, but even there I might think I have line splitting when it's really elements.  I wish there were enough of us on this list to put things to a vote sometimes and in this case I'd bet that Roman's view would win overwhelmingly.   I myself almost always want lines.  Or elements.  Sometimes words, almost  never characters.





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