Created attachment 1917725 [details] Shell script to demonstrate and document the failure. Description of problem: As of bash 5.2.2-1, the following fragment from a 'sh' script fails with "command not found": echo $(eval my_alias) Version-Release number of selected component: bash-5.2.2-1 How reproducible: 100% Steps to Reproduce: See the attached shell script, meant to be self-explanatory, with caveats: The alternative shebang paths will have to be adapted to your test setup. The shebang shells include '-u'. That does not affect the behavior; I always include it for safety (imagine 'rm -rf $undef/*' ). Actual results: "command not found" failure. Expected results: Proper execution of the alias. Additional info: bash-5.2.2-2 also fails. The failure did not occur in bash-5.1.16-3 . The failure happens only with 'sh', not 'bash'. The failure also happens in an interactive 'sh'. In the comments in the attached script, note the difference in the default 'shopt expand_aliases', 'sh' (on) vs. 'bash' (off). Behavior is the same with `` as with $() . Behavior is the same if the $() is quoted: "$()". Yes, the 'eval' in the attached script is in this case unnecessary, but it was triggering the problem in an complex application that did require it.
I just discovered another expansion failure, this time with numeric expansion, not 'eval': #!/bin/sh -u shopt -s expand_aliases alias narf="echo 123" echo $(narf) echo $(( $(narf) )) The first echo works, the second fails with "narf: command not found". Failure pattern is the same described in attachment 1917725 [details], most importantly: Fails with 'sh' from bash-5.2.2-{1,2} OK with 'sh' from bash-5.1.16-3 OK with any 'bash' (Adapt the shebang path for those versions.)
Neither error (attachment 1917725 [details], or that in comment 1) occurs in bash-5.2.9-3.fc37.x86_64 .
Possibly fixed by bash-5.2 patch 7 in upstream[1]. [1] https://git.savannah.gnu.org/cgit/bash.git/commit/?id=6ddc9cf242078c02c626ec60ee139c586da49bad