[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Parse error in bash 5.2+ with CHLD trap and 2 or more $() in a command
From: |
Emanuele Torre |
Subject: |
Parse error in bash 5.2+ with CHLD trap and 2 or more $() in a command |
Date: |
Wed, 6 Sep 2023 01:00:52 +0200 |
User-agent: |
Mutt/2.2.11 (2023-08-18) |
If you have a CHLD trap set, and you run any command that has more than
one command substitution, or an array subscript with more than one
command substituion in an arithmetic context, or also in a prompt
string, you will get parse errors.
$ ./bash -c 'trap : CHLD; let "x[\$(exit 20)0]"'
$ ./bash -c 'trap : CHLD; let "x[\$(exit 20)\$(exit 30)0]"'
./bash: trap: line 2: unexpected EOF while looking for matching `)'
./bash: command substitution: line 2: syntax error near unexpected token `)'
./bash: command substitution: line 2: `exit 30)0'
$ ./bash -c 'trap ":" CHLD; foo=$(exit 20)$'
$ ./bash -c 'trap ":" CHLD; foo=$(exit 20)$(exit 30)'
./bash: trap: line 2: unexpected EOF while looking for matching `)'
./bash: command substitution: line 2: syntax error near unexpected token `)'
./bash: command substitution: line 2: `exit 30)'
$ ./bash -c 'trap ":" CHLD; : "$(exit 20)"; : "$(exit 30)"'
$ ./bash -c 'trap ":" CHLD; : "$(exit 20)" "$(exit 30)"'
./bash: trap: line 2: unexpected EOF while looking for matching `)'
./bash: command substitution: line 2: syntax error near unexpected token `)'
./bash: command substitution: line 2: `exit 30)"'
$ ./bash -c 'trap ":" CHLD; x="\$(exit 20)"; : "${x@P}"'
$ ./bash -c 'trap ":" CHLD; x="\$(exit 20)\$(exit 30)"; : "${x@P}"'
./bash: trap: line 2: unexpected EOF while looking for matching `)'
./bash: command substitution: line 2: syntax error near unexpected token `)'
./bash: command substitution: line 2: `exit 30)'
I can reproduce this bug in bash 5.2, and on the devel branch.
o/
emanuele6
- Parse error in bash 5.2+ with CHLD trap and 2 or more $() in a command,
Emanuele Torre <=