Open sophiakoulen opened 1 year ago
Okay, i understand the issue now.
export is broken when the variable contains spaces.
Example:
export var="a! b$ c?"
creates a variable that contains spaces.
now, when doing export var2=$var
, the field splitting expands this to: export var2=a! b$ c?
so b$
and c?
will be considered separate variables.
This is a tricky one. Because we cannot solve this by escaping spaces, since spaces do not need to be escaped. The core of the issue, is that bash parses assignments in a particular way.
What i can think of is creating an item with flag ASSIGNMENT, so that we know that we should not perform field-splitting on it. But to do it right this demands quite some thinking, and updating the tokenizer and the parser and the expansion and the export builtin. Maybe not realistic to fix this before eval.
Well, maybe it is doable. We just need to parse the =
token as meaning something like assignment value
.
t_item with flag ASSIGNMENT_VALUE will not be splitted. (We already handle not splitting with heredocs).
And once we expanded stuff export is agnostic about this.
On my windows pc with WSL2: