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.97k stars 332 forks source link

Error on case toggle "~~" #1026

Closed mayrholu closed 10 months ago

mayrholu commented 10 months ago

When using case toggle such as echo ${PROJECT~~} an (unintuitive) error is thrown: <file, line...>: LitWord cannot be followed by a word

Remove the ~~ and the error is gone.

Let me know if you need additional info.

mvdan commented 10 months ago

Where is this language feature documented? I can't find it in man bash, nor by googling for "shell case toggle".

mayrholu commented 10 months ago

Check for example this guide

mvdan commented 10 months ago

Interesting, and it does work, although Bash appears to not have it documented at all and the only test for it is disabled.

I'm very reluctant to support a language feature that isn't documented. For all we know, it could be an accident or a historical feature that is in some stage of removal.

mvdan commented 10 months ago

I'm going to close this for now per the above - this is not planned as long as it's not documented. Happy to reopen if new information is brought forward.