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

Hm, I wasn't aware of this detail.  I see it's mentioned in zshexpn(1)
but don't see anything in the FAQ.  Worth mentioning?


diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
index 7d46e9192..d8c1fe2dd 100644
--- a/Etc/FAQ.yo
+++ b/Etc/FAQ.yo
@@ -1081,6 +1081,11 @@ sect(Comparisons of forking and non-forking command substitution)
   bash and ksh, so in emulation modes, newlines are stripped from command
   output (not from mytt(REPLY) assignments).
 
+  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.
+
   When mytt(command) is myem(not) a builtin, mytt(${ command }) does fork, and
   typically forks the same number of times as mytt($(command)), because in
   the latter case zsh usually optimizes the final fork into an exec.


-- 
vq




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