Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
BolunThompson opened this issue Nov 5, 2024 · 3 comments

Comments

@BolunThompson
Copy link

BolunThompson commented Nov 5, 2024

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

@BolunThompson BolunThompson changed the title Escape sequences in variables aren’t parsed, causing problems with new Bash versions Escape sequences in ANSI-C quoted strings aren’t parsed, causing problems with new Bash versions Nov 6, 2024
@angelhof
Copy link
Member

angelhof commented Nov 6, 2024

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
Copy link
Author

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
Copy link
Member

angelhof commented Nov 6, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants