Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16356

Re: Command substitution

From Eli Schwartz <eschwartz@archlinux.org>
Newsgroups gnu.bash.bug
Subject Re: Command substitution
Date 2020-06-02 22:02 -0400
Message-ID <mailman.1030.1591149794.2541.bug-bash@gnu.org> (permalink)
References <87mu5kgbxu.fsf@hobgoblin.ariadne.com> <8e513f8b-c541-ba1e-5f00-85c0afd6068f@archlinux.org>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 6/2/20 9:44 PM, Dale R. Worley wrote:
> Naively, I expect that
> 
>     FOO="$( command2 )"
>     command1 $FOO
> 
> has the same effect as
> 
>     command1 $( command2 )
> 
> and
> 
>     FOO="$( command2 )"
>     command1 "$FOO"
> 
> has the same effect as
> 
>     command1 "$( command2 )"
> 
> Has anyone pushed the boundaries of this and can tell me whether there
> are gotchas?

What boundaries were you expecting? If this is related to the thread
about the value of $? after command substitution in variable assignment
vs. command arguments... that's already a gotcha according to many
people. Despite being both documented and logical.

Aside for that, obviously in one case you don't have a "FOO" variable in
the shell environment, which does seem like a fairly major difference as
it's a very common pattern for people to reuse the results of command
substitution multiple times.

Perhaps you meant to say "executes the same command process" instead of
"has the same effect"?

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Command substitution Eli Schwartz <eschwartz@archlinux.org> - 2020-06-02 22:02 -0400

csiph-web