binpash / pash

PaSh: Light-touch Data-Parallel Shell Processing
MIT License
555 stars 39 forks source link

Escape sequences in ANSI-C quoted strings aren’t parsed, causing problems with new Bash versions #726

Open BolunThompson opened 1 week ago

BolunThompson commented 1 week ago

In Bash 5.2.21, declare -p prints the values of shell variables containing escape sequences using ANSI-C quoted strings. This has changed since Bash 5.0.17, in which declare -p literally writes the control codes. The compiler does not interpret escape sequences when reading in variables. This causes incorrect behavior with Bash 5.2.21. For instance, it interprets IFS=$' \t\n' literally, leading to the shell splitting arguments incorrectly.

The test suite doesn’t catch this since it runs on Ubuntu 20.04 using (presumably) Bash 5.0.17. However, the tests fail on Ubuntu 24.04 using Bash 5.2.21.

I created a PR with a potential fix in the sh-expand repo.

Tested on: Bash 5.0.17 on Ubuntu 20.04 Bash 5.2.21 on Ubuntu 20.04 & 24.04

angelhof commented 1 week ago

Thanks for catching that! Does the PR still hold? I see it is closed? We could also add an ubuntu 24 test in the CI to ensure this is caught.

BolunThompson commented 1 week ago

It does for the main branch, but, in the future branch, the file in question (env_var_utils.py) has been moved to sh-expand. I just opened another PR in that repo, but I can reopen this PR if there’s a desire to merge it into main.

angelhof commented 1 week ago

Thanks, no that is the right approach! I commented on the sh-expand PR.