mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
6.98k stars 332 forks source link

RFC/E: more simplification / dropping of unnecessary quotes #996

Open scop opened 1 year ago

scop commented 1 year ago

It seems there's room for some more removal of unnecessary quotes on simplify; to my knowledge word splitting does not occur:

I don't know offhand how this is for other shells besides bash, but thought I'd drop the suggestion here for comments already based just on the bash info.

akinomyoga commented 1 year ago

Similarly, in Bash, case $word in and here strings <<< $word are unnecessary in most cases. Some notes:

scop commented 1 year ago

Thanks for the info. What I'm specifically thinking of are the simple "$foo" cases. Any known issues dropping the quotes from them in the mentioned contexts?

akinomyoga commented 1 year ago

For the simple case "$foo", I think there aren't any problems in the mentioned contexts at least in Bash. They can be always unquoted in