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


Groups > gnu.bash.bug > #16356

Re: Command substitution

Path csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Eli Schwartz <eschwartz@archlinux.org>
Newsgroups gnu.bash.bug
Subject Re: Command substitution
Date Tue, 2 Jun 2020 22:02:55 -0400
Lines 87
Approved bug-bash@gnu.org
Message-ID <mailman.1030.1591149794.2541.bug-bash@gnu.org> (permalink)
References <87mu5kgbxu.fsf@hobgoblin.ariadne.com> <8e513f8b-c541-ba1e-5f00-85c0afd6068f@archlinux.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="zOqsa7pqpDAoRUjwRJfXUazAO1KZVvOkn"
X-Trace usenet.stanford.edu 1591149794 3495 209.51.188.17 (3 Jun 2020 02:03:14 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
X-Spam-BL-Results
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1591149780; bh=eyaDIL7sCoq0Gs87I/QKRC9QqrLh7XJeLzt2g/DeG/w=; h=Subject:To:References:From:Date:In-Reply-To; b=LK8H4AfIT3FJq0WL/4KlK1xIolCFhBg/5LGI+P62cJePW0F+T9hUbZnLKhWVAvdbA Ia0XdFdVYZLoBLODP9ZJ9gvGjdiQexUXRPoTFcUbLkx6KMxBG8/VaFXAPkNG2myzjj sM6WbuOALYZjFCDIuxkUGM7D1SJrNTRu2ytFkZAmHpesKQ/watVAFJ5vuRf4QO4nL1 Rsbko7neIECG5nmbPWLBKLS7ZupSZV+BAeyIUk/IZg26W+EDwKlxI+3A2RD9CoZ7wE BPZ489OUvbNI975GBvg9iAXe1Ollni/nw1mrHqH3ZXO7EvwWPF4we0b4S4qt/B5xwu yKSosfSuhIl90mtJ2BJqltkksvQlmrfSq1WGZE1wGpY81/hOBaApFfe+3niNhqWsaz SXbVRri4BGZnDgJaz6Kr9ffl6SbsR9oBhCXPsu1PG7a3xauaLgDyPQ1uLohkUKg/GT 3L91mRhTjyAC27IFhoVMctvkSZKyXOSI7zgk3NCfOkPYAEsZGLshqVUDfl+btbSi1/ v6amrIMWdzPRE9eRajBOLzo8yFx1zsoLyc/VslIY35ohohpMMLhbCen5u7d0tfN3Bj uU4Tc228kVaxG9MC3y3FORahIZC7WyY7Wp3RU5BPIssqWUD7lu11kV2CQC1MN7g2Mk w+XwMSH6e3fm7pJOca16Q32o=
X-Clacks-Overhead GNU Terry Pratchett
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0
In-Reply-To <87mu5kgbxu.fsf@hobgoblin.ariadne.com>
Received-SPF pass client-ip=88.198.91.70; envelope-from=eschwartz@archlinux.org; helo=orion.archlinux.org
X-detected-operating-system by eggs.gnu.org: First seen = 2020/06/02 22:03:05
X-ACL-Warn Detected OS = Linux 2.2.x-3.x [generic] [fuzzy]
X-Spam_score_int -43
X-Spam_score -4.4
X-Spam_bar ----
X-Spam_report (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN
X-Spam_action no action
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <8e513f8b-c541-ba1e-5f00-85c0afd6068f@archlinux.org>
X-Mailman-Original-References <87mu5kgbxu.fsf@hobgoblin.ariadne.com>
Xref csiph.com gnu.bash.bug:16356

Show key headers only | 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