-
Notifications
You must be signed in to change notification settings - Fork 3
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
[KNOWN ISSUE] Word splitting and filename expansion should not be performed when assigning values to variables #295
Comments
1 task
itislu
changed the title
[BUG] Word splitting and filename expansion are not performed when assigning values to env variables
[KNOWN ISSUE] Word splitting and filename expansion are not performed when assigning values to env variables
Apr 1, 2024
itislu
changed the title
[KNOWN ISSUE] Word splitting and filename expansion are not performed when assigning values to env variables
[KNOWN ISSUE] Word splitting and filename expansion should not be performed when assigning values to env variables
Jun 29, 2024
itislu
changed the title
[KNOWN ISSUE] Word splitting and filename expansion should not be performed when assigning values to env variables
[KNOWN ISSUE] Word splitting and filename expansion should not be performed when assigning values to variables
Jul 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Definition:
Test case:
Result:
Reminder what word splitting usually does:
Reference:
https://www.gnu.org/savannah-checkouts/gnu/bash/manual/html_node/Shell-Parameters.html
Explanation
Note
Thanks a lot to @gwolf-011235!
The following is directly quoted from him.
Bash has flags for its builtins, one of which is "ASSIGNMENT_BUILTIN", which indicates "This builtin takes assignment statements." - builtins.h
This flag is checked in function fix_assignment_words() which has the amusing description: "This is a hack to suppress word splitting for assignment statements given as arguments to builtins with the ASSIGNMENT_BUILTIN flag set." - execute_cmd.c
This function is called in execute_simple_command() before the words get expanded with expand_words() - execute_cmd.c
If you hide export from bash before expansion takes place you can achieve the result you were expecting:
gives you
The text was updated successfully, but these errors were encountered: