Bash 5.3 bug - POSIX process substitution $() handling error with embedded comments

Jari Aalto <[email protected]>
Newsgroups gmane.comp.shells.bash.bugs
Message-ID <CAOU7Hic8Odr9w2mKq4VgdJMMTo080Xojivbhr31P3cQ1dEGsmw@mail.gmail.com>
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -Werror=implicit-function-declaration
-fstack-protector-strong -fstack-clash-protection -
uname output: Linux congo 6.1.0-6-amd64 #1 SMP PREEMPT_DYNAMIC Debian
6.1.15-1 (2023-03-05) x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.3
Patch Level: 3
Release Status: release (Debian/testing)

Description:
        POSIX command substitution does not work with comments

Repeat-By:
        See code below.
        - The old backtics `` work
        - The modern $() doesn't

Fix:
        The process substitution is defined in POSIX and
        should work identically in both cases.

Command:

bash -x <code>

Output:

++ echo 1
+ x=1
+ x=
posix-test--process-substitution.sh: line 13: unexpected EOF while
looking for matching `)'

Code: posix-test--process-substitution.sh

#! /bin/sh

# OK
x=$(echo 1)

# OK
x=`# comment`

#  Syntax error: end of file unexpected (expecting ")")
x=$(# comment)

# End of file
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.