From 0fccdf0d57fb8ed4b88df6681d15822f3c4e784f Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Wed, 24 Jan 2024 17:42:36 -0800 Subject: 52476 + cf. 52479: more FAQs about nofork substitution --- Etc/FAQ.yo | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'Etc') diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo index 270a04608..7d46e9192 100644 --- a/Etc/FAQ.yo +++ b/Etc/FAQ.yo @@ -1067,6 +1067,44 @@ label(211) quoted, that is, included in a quoted string or prefixed by backslash. These substitutions first become usable after zsh 5.9. +sect(Comparisons of forking and non-forking command substitution) + + mytt(${ command }) and variants may change the caller's options by using + mytt(setopt) and may modify the caller's local parameters, including the + positional parameters mytt($1), mytt($2), etc., via both assignments and + mytt(set -- pos1 pos2 etc). Nothing that happens within mytt($(command)) + affects the caller. + + mytt($(command)) removes trailing newlines from the output of mytt(command) + when substituting, whereas mytt(${ command }) and its variants do not. + The latter is consistent with mytt(${|...}) from mksh but differs from + bash and ksh, so in emulation modes, newlines are stripped from command + output (not from mytt(REPLY) assignments). + + 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. + + Redirecting input from files has subtle differences: + + mytt($(