sh
sh copied to clipboard
A shell parser, formatter, and interpreter with bash support; includes shfmt
shfmt is incorrectly reporting an "unclosed here-document" error for a bash script that uses the
Before formatting: ```bash $ echo "`echo \"foobar\"`" foobar ``` After formatting: ```bash $ echo "$(echo \"foobar\")" "foobar" ``` Solution: quotes in a quoted backtick substitution should be unescaped ```bash $...
Example `file.sh`: ``` #!/bin/sh ( # Comment true ) ``` Running `shfmt -w -l` 1st time produces (2 spaces in front of the comment): ``` #!/bin/sh ( # Comment true...
Using `"${array[@]@Q}"` does not work as expected (I tried some other operators as well and assume this applies to all operators, not just `@Q` specifically). ```console $ bash -c 'var="with...
**testdata: Fix missing zsh files** These lines were being rendered into the contents of `shebang-nospace` rather than separate files because they were missing the trailing `--` delimiters. It seems that...
#1096
@msanders https://github.com/mvdan/sh/issues/288#issuecomment-579582229 > It might make sense to add a -z or -0 flag for shfmt -f to use safely with xargs -0. (See e.g. find -print0, git ls-files -z,...
You should prefix the `.editorconfig` properties defined by `shfmt`. Similar to what JetBrains does: [Editorconfig](https://www.jetbrains.com/help/idea/editorconfig.html#heqdcl_31) > Generic IntelliJ options that have the `ij_` prefix and are applicable to all languages...
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. ```shell...
shfmt currently always removes the optional left parenthesis on `case`, which is part of the base POSIX sh language. Although nobody likes to type it on the command-line, the balanced...