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

Re: Counting characters in command output?



On Thu, Feb 15, 2024, at 8:53 PM, Bart Schaefer wrote:
> If you want command substitution without word splitting, then in
> whatever the next version ends up being called you have
>    ${ command }
> to do that for you

Is it also the case that ${ command} runs in the current shell rather than a subshell and can therefore have side effects (if it's a function/builtin, of course)? I seem to recall seeing that syntax used that way before, but it may have been in a different shell.

On Fri, Feb 16, 2024 at 1:03 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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.

Even ${| REPLY=(a b c)} behaves like a scalar (joins the array), which
I suppose is also worth mentioning.  Will consider wording over the
weekend when I have more time.



--
Mark J. Reed <markjreed@xxxxxxxxx>


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