[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nofork command substitution
From: |
Dale R. Worley |
Subject: |
Re: nofork command substitution |
Date: |
Thu, 18 May 2023 22:14:28 -0400 |
Chet Ramey <chet.ramey@case.edu> writes:
> Bash allows the close brace to be joined to the remaining
> characters in the word without being followed by a shell metacharacter
> as a reserved word would usually require.
I had to read this a couple of times to figure out what it means. In
particular "the word" isn't well-bound here. Perhaps better is
> The characters immediately following the close brace continue the word
> that the command substitution is part of; the close brace need not be
> followed by a shell metacharacter as a reserved word would usually
> require.
This text is clear in its description of the behavior but entirely
unclear regarding what the point is:
> If the first character is a '|', the construct expands to the value of
> the 'REPLY' shell variable after COMMAND executes, without removing any
> trailing newlines, and the standard output of COMMAND remains the same
> as in the calling shell. Bash creates 'REPLY' as an initially-unset
> local variable when COMMAND executes, and restores 'REPLY' to the value
> it had before the command substitution after COMMAND completes, as with
> any local variable.
My guess is that the intention is for COMMAND to be "read" with no
names:
${| read; }
If so, can you make this an example for the "${|" form?
Also, can you clarify the semantics on this point: The text above says
"the construct expands to the value of the 'REPLY' shell variable after
COMMAND executes, without removing any trailing newlines". However, the
documentation of "read" says: "If no names are supplied, the line read,
without the ending delimiter but otherwise unmodified, is assigned to
the variable REPLY."
So the sequence of processing is: read inputs a line; read deletes the
ending newline and assigns the remainder to REPLY; command substitution
obtains the value of REPLY (which does not contain a newline); command
substitution returns that value "without removing any trailing
newlines".
Is that what you intend the code to do/what the code does?
Dale
- nofork command substitution, Chet Ramey, 2023/05/15
- Re: nofork command substitution, Ángel, 2023/05/16
- Re: nofork command substitution,
Dale R. Worley <=
- Re: nofork command substitution, Robert Elz, 2023/05/19
- Re: nofork command substitution, alex xmb ratchev, 2023/05/19
- Re: nofork command substitution, alex xmb ratchev, 2023/05/19