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

Check that keys of assoc array literals are quoted #652

Open
andychu opened this issue Mar 9, 2020 · 1 comment
Open

Check that keys of assoc array literals are quoted #652

andychu opened this issue Mar 9, 2020 · 1 comment

Comments

@andychu
Copy link
Contributor

andychu commented Mar 9, 2020

From #648

The following is the case where the type of the variable cannot be determined statically (which seems not be prohibited by Oil):

$ bin/osh -c 'v=A; declare -$v d=([a]=123); echo ${d["a"]}'
123
@andychu
Copy link
Contributor Author

andychu commented Mar 9, 2020

@akinomyoga I wrote a comment about this issue here:

https://github.com/oilshell/oil/blob/master/osh/word_.py#L518

Basically A=([k]=v) in Oil has to be an associative array; it can't be an indexed array.

However I can see it's a bit confusing nonetheless. We could add a check for it, but I noticed that there are tons of scripts that use it unquoted.

I guess we would hide it behind shopt -s parse_strict_array or something.

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

No branches or pull requests

1 participant