[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Incorrect alias expansion within command substitution
From: |
L A Walsh |
Subject: |
Re: Incorrect alias expansion within command substitution |
Date: |
Wed, 02 Feb 2022 05:25:30 -0800 |
User-agent: |
Thunderbird |
On 2022/01/31 20:40, Martijn Dekker wrote:
On the latest code from the devel branch:
GNU bash, versie 5.2.0(35)-alpha (x86_64-apple-darwin18.7.0)
Reproducer script:
shopt -s expand_aliases
alias let='let --'
set -x
let '1 == 1'
: $(let '1 == 1')
Output:
+ let -- '1 == 1'
++ let -- -- '1 == 1'
foo: line 5: let: --: syntax error: operand expected (error token is "-")
+ :
The alias is incorrectly expanded in the command substitution,
duplicating the '--' argument and causing a syntax error.
----
I can't say for sure, but it would be interesting if anyone else
has this result in a bash with aliases on by default:
I.e. My bash is posix compliant by default w/r/t aliases:
env -i /bin/bash --noprofile --norc
bash-4.4$ shopt -p expand_aliases
shopt -s expand_aliases
and it doesn't show the above error:
bash-4.4$ alias let='let --'
bash-4.4$ set -x
bash-4.4$ let '1 == 1'
+ let -- '1 == 1'
bash-4.4$ : $(let '1 == 1')
++ let -- '1 == 1'
+ :
It may not be the case, but to me, looked like the alias for 'let' had
been disabled
in the $() subshell as per standard bash behavior of disabling aliases
on startup.
I.e. if you configure bash to be posix compliant w/r/t aliases on
shell startup, this seems to fix the above problem.
- Re: Incorrect alias expansion within command substitution, (continued)
- Re: Incorrect alias expansion within command substitution, Alex fxmbsw7 Ratchev, 2022/02/05
- Re: Incorrect alias expansion within command substitution, Alex fxmbsw7 Ratchev, 2022/02/05
- Re: Incorrect alias expansion within command substitution, Lawrence Velázquez, 2022/02/05
- Re: Incorrect alias expansion within command substitution, Chet Ramey, 2022/02/05
- Re: Incorrect alias expansion within command substitution, Alex fxmbsw7 Ratchev, 2022/02/05
Re: Incorrect alias expansion within command substitution, Martijn Dekker, 2022/02/02
Re: Incorrect alias expansion within command substitution,
L A Walsh <=
Message not available
Re: Incorrect alias expansion within command substitution, Chet Ramey, 2022/02/02
Re: Incorrect alias expansion within command substitution, Robert Elz, 2022/02/02
Re: Incorrect alias expansion within command substitution, Alex fxmbsw7 Ratchev, 2022/02/03