You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If bash's extended globbing is on, some programs are suddenly valid:
shopt -s extglob
echo foo@(bar)
Normally, this fails as ( is a token:
$ echo 'echo @(foo)' | bash
bash: line 1: syntax error near unexpected token `('
bash: line 1: `echo @(foo)'
$ echo 'echo @(foo)' | shfmt
1:7: a command can only contain words and redirects
I see two possible options:
Change the behaviour of the parser whenever a shopt statement is parsed (ugh)
Always parse extended globbing stuff in the bash mode
The first option would make the parser even more complex, as it would change behaviour not only depending on the context, but also depending on what statements it has parsed.
The second option is somewhat cleaner, but I see some minor disadvantages:
Some invalid bash programs will be accepted (which is okay for shfmt)
If this parser is ever used for anything serious, another package (like an interpreter/executor) would have to take care of erroring if it finds an extended globbing node when not in extglob mode
The text was updated successfully, but these errors were encountered:
If bash's extended globbing is on, some programs are suddenly valid:
Normally, this fails as
(
is a token:I see two possible options:
shopt
statement is parsed (ugh)The first option would make the parser even more complex, as it would change behaviour not only depending on the context, but also depending on what statements it has parsed.
The second option is somewhat cleaner, but I see some minor disadvantages:
shfmt
)extglob
modeThe text was updated successfully, but these errors were encountered: