shfmt

Updated: 22 February 2025

A shell program formatter https://github.com/mvdan/sh

Check a shell program and specify 4 spaces of indentation

shfmt -i 4 my-bash-script.sh

Show a diff between actual and desired formatting

shfmt -d my-bash-script.sh

Directly update the file being checked

shfmt -w my-bash-script.sh

Run shfmt from Doccker

docker run --rm -i mvdan/shfmt:v3.10.0 -ci -bn --diff -i=4 < check-me.sh

Leave a comment