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 you have an incorrect sh shebang while using bash's test syntax shfmt breaks the script. Formatting works correctly with a bash shebang, and with no shebang at all.
What exactly do you want to see happen here? The original happens to be valid posix shell, which is unfortunate, but the parser and formatter are technically correct in continuing if they can.
If what you mean is "the parser should reject [[ in POSIX mode, telling the user it's bash syntax", we could possibly do that and it would probably lead to better UX for the vast majority of users, but I wonder if it would technically break with the POSIX spec. It just says that some implementations may treat [[ as a reserved keyword with unspecified results.
Ah, I was not aware that the original code was valid posix shell :^(.
Rejecting (or maybe warning about) [[ in posix mode is likely to save a few souls, but not sure what that does for posix compliance.
I imagine this case could come up quite a lot, as #!/bin/sh is a common incantation, and most people don't know the difference between posix sh and bash...
If you have an incorrect
sh
shebang while using bash's test syntaxshfmt
breaks the script. Formatting works correctly with a bash shebang, and with no shebang at all.The text was updated successfully, but these errors were encountered: