bug-bash
[Top][All Lists]
Advanced

[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.







reply via email to

[Prev in Thread] Current Thread [Next in Thread]