Closed sereysethy closed 4 years ago
I verified in the bash source code, here it is the comment that I found:
/* Variable names in assignment statements may contain only letters,
digits, and `_'. */
So variable name can be letters, digits and _
. I also added a test case, the test passes. Please check.
I think this will also accept variable names that start with a digit, no?
No, you cannot have variables starting with a digit, this will have a conflict with the reserved parameters (positional parameters) passed to a script or a function ${N}
where N
is digit.
Doesn't your change allow that?
Thanks for the change.
This function is based on http://git.savannah.gnu.org/cgit/bash.git/tree/general.c?id=df2c55de9c87c2ee8904280d26e80f5c48dd6434#n263
Can you make sure the change you're making is correct with respect to how Bash handles this?
Also, can you please add a test?
Thanks!