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