Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Counting characters in command output?
- X-seq: zsh-users 29682
- From: Lawrence Velázquez <larryv@xxxxxxx>
- To: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- Cc: zsh-users@xxxxxxx
- Subject: Re: Counting characters in command output?
- Date: Thu, 15 Feb 2024 23:53:26 -0500
- Archived-at: <https://zsh.org/users/29682>
- Feedback-id: iaa214773:Fastmail
- In-reply-to: <CAH+w=7brXaXfsCi5wXnYNZgZmKVqis6u3T3bPtQuqCHcbpnqKA@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAA=-s3zUSg4KYSGTNVSi80u_=9C9kg8nk2CYx2Zewiu70rgSZQ@mail.gmail.com> <CAN=4vMrWzYgyGYghHsp1jEcnN=X+bUM8LDXviL4V+mHtnHpq8A@mail.gmail.com> <CAA=-s3z3dwdPY4ahJSOZZC7_vH5VwUJxt-UEo9BW=8qzu0WTSg@mail.gmail.com> <CAN=4vMp1gcSbE19cbKoW9JJMs_dVhedbOYrwZRVQjbuEg0rNqw@mail.gmail.com> <CAH+w=7brXaXfsCi5wXnYNZgZmKVqis6u3T3bPtQuqCHcbpnqKA@mail.gmail.com>
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