X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=shfmt%2FREADME.md;h=40eef2d57652cc590ea0cf8f933a45c42b935b02;hb=ee740c9070ac7f6f2bd063a799e7395a387113d5;hp=9b9f2ff9e7275681100792862a34f82e8a859f84;hpb=49498cc112d812a87d011c7bcbbf810c779f72f7;p=webi-installers%2F.git diff --git a/shfmt/README.md b/shfmt/README.md index 9b9f2ff..40eef2d 100644 --- a/shfmt/README.md +++ b/shfmt/README.md @@ -7,65 +7,50 @@ tagline: | To update or switch versions, run `webi shfmt@stable` or `webi shfmt@beta`, etc. -# Cheat Sheet +## Cheat Sheet -> shfmt is a shell parser, formatter and interpretter that supports POSIX Shell, Bash and mksh. +> shfmt is a shell parser, formatter and interpretter that supports POSIX Shell, +> Bash and mksh. Usage: `shfmt ` -Note: If given path is directory, all shell scripts in the directory will be used. +Note: If given path is directory, all shell scripts in the directory will be +used. -## Flags: +### Frequently used flags: -*-version* +```txt +-version Show version and exit. -*-l* +-l List files whose formatting differs from shfmt's. -*-w* +-w Write result to file instead of stdout. -*-d* +-d Error with a diff when the formatting differs. -*-s* +-s Simplify the code. -*-mn* - Minify the code to reduce its size (implies -s). - -*-ln* - Language variant to parse (bash/posix/mksh/bats, default "bash"). - -*-p* - Shorthand for -ln=posix. - -*-filename* str - Provide a name for the standard input file. - -*-i* - Indent: 0 for tabs (default), >0 for number of spaces. - -*-bn* - Binary ops like && and | may start a line. - -*-ci* - Switch cases will be indented. +-f + Recursively find all shell files and print the paths. +``` -*-sr* - Redirect operators will be followed by a space. +### Examples -*-kp* - Keep column alignment paddings. +To list files being formatted and write directly to file -*-fn* - Function opening braces are placed on a separate line. +```bash +shfmt -l -w +``` -*-f* - Recursively find all shell files and print the paths. +To show differences between shfmt formatting and original file formatting -*-tojson* - Print syntax tree to stdout as a typed JSON. +```bash +shfmt -d +``` -See https://github.com/mvdan/sh for more info. \ No newline at end of file +See https://github.com/mvdan/sh for more info.