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

Re: Counting characters in command output?



On 2/16/24, Lawrence Velázquez <larryv@xxxxxxx> wrote:
> On Fri, Feb 16, 2024, at 1:03 PM, Bart Schaefer wrote:
>> On Thu, Feb 15, 2024 at 8:55 PM Lawrence Velázquez <larryv@xxxxxxx>
>> wrote:
>>>
>>> +  Unless enclosed in double quotes, the expansion of mytt($(command))
>>> is
>>> +  split on mytt(IFS).  In contrast, and contrary to bash and ksh,
>>> unquoted
>>> +  mytt(${ command }) and its variants are not split unless the
>>> +  mytt(SH_WORD_SPLIT) option is set.
>>
>> That's not quite accurate, though.
>>
>> % print -l ${|reply| reply=(a b c)}
>> a
>> b
>> c
>>
>> It's only ${| REPLY=...} and ${ command } that always behave like
>> scalars.
>
> Ah, you got me.  I only tested out ${ command }, and I overlooked
> that var in ${|var| command } could be an array.

Arguably the statement is still correct; the value is not split in
this case either, it is already an array.
% print -l ${|reply| reply=(a\ b c d)}
a b
c
d

notice how 'a b' is not split on $IFS.

-- 
Mikael Magnusson




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