shfmt(1) General Commands Manual shfmt(1) (NAME) shfmt - (SYNOPSIS) shfmt [flags] [path...] (DESCRIPTION) shfmt . (-) . . EditorConfig . EditorConfig . -i=0 . shfmt . . (OPTIONS) (Generic flags) --version . -l[=0], --list[=0] shfmt -l=0 (null) . -w, --write stdout. -d, --diff diff . diff . NO_COLOR TERM=dumb . FORCE_COLOR . --apply-ignore (ignore) EditorConfig . . stdin . stdout . --filename str . EditorConfig stdin EditorConfig . (Parser flags) -ln, --language-dialect (bash/posix/mksh/bats/zsh auto). auto foo.mksh . shebang #!/bin/sh . bash (fallback) . .sh : posix shebang . -p, --posix -ln=posix. -s, --simplify . (Printer flags) -i, --indent : 0 () >0 . -bn, --binary-next-line && | . -ci, --case-indent case . -sr, --space-redirects . -kp, --keep-padding . (DEPRECATED) . : https://github.com/mvdan/sh/issues/658 -fn, --func-next-line . -mn, --minify ( -s ). (Utility flags) -f[=0], --find[=0] -f=0 (null) . --to-json stdout JSON . --from-json stdin JSON . (EXAMPLES) : shfmt -l -w . (CI) diff : shfmt -d . (Google) : shfmt -i 2 -ci -bn EditorConfig : [*.sh] # -i=4 indent_style = space indent_size = 4 # --language-dialect shell_variant = posix simplify = true binary_next_line = true # --case-indent switch_case_indent = true space_redirects = true keep_padding = true # --func-next-line function_next_line = true minify = true # "third_party" shfmt # "shfmt -l -w .". # "shfmt -w third_party/foo.sh" "shfmt --filename=third_party/foo.sh" # --apply-ignore . [third_party/**] ignore = true EditorConfig `[[shell]]` `[[bash]]` `[[zsh]]` shebang . EditorConfig . shfmt bash -n . UTF-8 : $ echo '${foo:1 2}' | bash -n $ echo '${foo:1 2}' | shfmt >/dev/null 1:9: not a valid arithmetic operator: 2 $ echo 'foo=(1 2)' | bash --posix -n $ echo 'foo=(1 2)' | shfmt -p >/dev/null 1:5: arrays are a bash feature (AUTHORS) Daniel Marti . : . 2026-04-07 shfmt(1)