Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
DescriptionMiciah Dashiel Butler Masters
2013-09-25 14:44:33 UTC
Description of problem:
If I enclose a command substitution within double-quotes, and the command includes a double-quoted string, Bash performs brace expansion on the command before performing command substitution.
Version-Release number of selected component (if applicable):
bash-4.1.2-15.el6_4.x86_64
I also ran through the Steps to Reproduce on Fedora 19 with bash-4.2.45-1.fc19.x86_64 and got the same results.
How reproducible:
Completely.
Steps to Reproduce:
1. printf '1=%s 2=%s\n' "$(echo {a,b})"
2. printf '1=%s 2=%s\n' "$(echo '{a,b}')"
3. printf '1=%s 2=%s\n' "$(echo "{a,b}")"
Actual results:
Step 1 prints "1=a b 2=" as expected.
Step 2 prints "1=a b 2=" as expected.
Step 3 prints "1=a b 2=" because {a,b} is expanded before the echo command is run.
Expected results:
Step 3 should print the same output as Step 1 and Step 2.
Additional info:
$ printf '1=%s 2=%s\n' "$(echo {a,b})"
1=a b 2=
$ printf '1=%s 2=%s\n' "$(echo '{a,b}')"
1={a,b} 2=
$ printf '1=%s 2=%s\n' "$(echo "{a,b}")"
1=a 2=b
$ printf '1=%s 2=%s\n' "`echo {a,b}`"
1=a b 2=
$ printf '1=%s 2=%s\n' "`echo '{a,b}'`"
1={a,b} 2=
$ printf '1=%s 2=%s\n' "`echo "{a,b}"`"
1=a 2=b
$ set -x
$ printf '1=%s 2=%s\n' "$(echo {a,b})"
++ echo a b
+ printf '1=%s 2=%s\n' 'a b'
1=a b 2=
$ printf '1=%s 2=%s\n' "$(echo '{a,b}')"
++ echo '{a,b}'
+ printf '1=%s 2=%s\n' '{a,b}'
1={a,b} 2=
$ printf '1=%s 2=%s\n' "$(echo "{a,b}")"
++ echo a
++ echo b
+ printf '1=%s 2=%s\n' a b
1=a 2=b
$ printf '1=%s 2=%s\n' "`echo {a,b}`"
++ echo a b
+ printf '1=%s 2=%s\n' 'a b'
1=a b 2=
$ printf '1=%s 2=%s\n' "`echo '{a,b}'`"
++ echo '{a,b}'
+ printf '1=%s 2=%s\n' '{a,b}'
1={a,b} 2=
$ printf '1=%s 2=%s\n' "`echo "{a,b}"`"
++ echo a
++ echo b
+ printf '1=%s 2=%s\n' a b
1=a 2=b
$
From the above, we can see that brace expansion is indeed happening before the command substitution is performed, with the result that the command echo "{a,b}" is expanded into two commands: echo a and echo b. Further, the problem is present with backtick syntax as well as $() syntax, but only with nested double-quote marks.
Thanks for the report.
It is fixed in bash-4.3-beta (first fix in alpha).
So far bash-4.3 is not released and beta is not part of Fedora. I'm not sure how difficult it will be to back port this fix.
(In reply to Miciah Dashiel Butler Masters from comment #0)
I am a bit confused by this, so let us make things absolutely clear:
> Steps to Reproduce:
> 2. printf '1=%s 2=%s\n' "$(echo '{a,b}')"> Actual results:
> Step 2 prints "1=a b 2=" as expected.> Additional info:
> $ printf '1=%s 2=%s\n' "$(echo '{a,b}')"
> 1={a,b} 2=
If I understand correctly, the actual (and also expected) result of Step 2 is the one with {a,b} (see Additional info) rather than the one provided in Actual results. As a consequence, the expected result is not Step 3 producing the same output as both Step 1 and 2 (since these are different from one another), but rather Step 3 should print the same message as Step 1.
Am I right?
Comment 7Miciah Dashiel Butler Masters
2014-06-03 16:24:08 UTC
I believe you are right. I must have made an error in my initial report. Sorry!
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
http://rhn.redhat.com/errata/RHBA-2014-1503.html
Description of problem: If I enclose a command substitution within double-quotes, and the command includes a double-quoted string, Bash performs brace expansion on the command before performing command substitution. Version-Release number of selected component (if applicable): bash-4.1.2-15.el6_4.x86_64 I also ran through the Steps to Reproduce on Fedora 19 with bash-4.2.45-1.fc19.x86_64 and got the same results. How reproducible: Completely. Steps to Reproduce: 1. printf '1=%s 2=%s\n' "$(echo {a,b})" 2. printf '1=%s 2=%s\n' "$(echo '{a,b}')" 3. printf '1=%s 2=%s\n' "$(echo "{a,b}")" Actual results: Step 1 prints "1=a b 2=" as expected. Step 2 prints "1=a b 2=" as expected. Step 3 prints "1=a b 2=" because {a,b} is expanded before the echo command is run. Expected results: Step 3 should print the same output as Step 1 and Step 2. Additional info: $ printf '1=%s 2=%s\n' "$(echo {a,b})" 1=a b 2= $ printf '1=%s 2=%s\n' "$(echo '{a,b}')" 1={a,b} 2= $ printf '1=%s 2=%s\n' "$(echo "{a,b}")" 1=a 2=b $ printf '1=%s 2=%s\n' "`echo {a,b}`" 1=a b 2= $ printf '1=%s 2=%s\n' "`echo '{a,b}'`" 1={a,b} 2= $ printf '1=%s 2=%s\n' "`echo "{a,b}"`" 1=a 2=b $ set -x $ printf '1=%s 2=%s\n' "$(echo {a,b})" ++ echo a b + printf '1=%s 2=%s\n' 'a b' 1=a b 2= $ printf '1=%s 2=%s\n' "$(echo '{a,b}')" ++ echo '{a,b}' + printf '1=%s 2=%s\n' '{a,b}' 1={a,b} 2= $ printf '1=%s 2=%s\n' "$(echo "{a,b}")" ++ echo a ++ echo b + printf '1=%s 2=%s\n' a b 1=a 2=b $ printf '1=%s 2=%s\n' "`echo {a,b}`" ++ echo a b + printf '1=%s 2=%s\n' 'a b' 1=a b 2= $ printf '1=%s 2=%s\n' "`echo '{a,b}'`" ++ echo '{a,b}' + printf '1=%s 2=%s\n' '{a,b}' 1={a,b} 2= $ printf '1=%s 2=%s\n' "`echo "{a,b}"`" ++ echo a ++ echo b + printf '1=%s 2=%s\n' a b 1=a 2=b $ From the above, we can see that brace expansion is indeed happening before the command substitution is performed, with the result that the command echo "{a,b}" is expanded into two commands: echo a and echo b. Further, the problem is present with backtick syntax as well as $() syntax, but only with nested double-quote marks.