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
7.1k stars 336 forks source link

interp: display all options for bash's `shopt` and explicitly state unsupported ones #877

Closed riacataquian closed 2 years ago

riacataquian commented 2 years ago

We don't support all of bash's shell options, at the moment we support these three:

$ gosh -c "shopt"
expand_aliases  off
globstar    off
nullglob    off

Bash actually has more options than what's listed above, see shopt documentation but we only print what's supported which could be misleading and unhelpful, eg when someone looks up for an option shopt | grep extglob, they'll get empty results.

Also trying to set an unsupported bash option leads to a confusing error message:

$ gosh -c "shopt -s extglob"
shopt: invalid option name "extglob"

We could improve the error message by explicitly saying it is instead unsupported.