refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / shfmt / README.md
1 ---
2 title: shfmt
3 homepage: https://github.com/mvdan/sh
4 tagline: |
5   shfmt: Format shell programs
6 ---
7
8 To update or switch versions, run `webi shfmt@stable` or `webi shfmt@beta`, etc.
9
10 ## Cheat Sheet
11
12 > shfmt is a shell parser, formatter and interpretter that supports POSIX Shell,
13 > Bash and mksh.
14
15 Usage: `shfmt <flags> <filepath>`
16
17 Note: If given path is directory, all shell scripts in the directory will be
18 used.
19
20 ### Frequently used flags:
21
22 ```txt
23 -version
24         Show version and exit.
25
26 -l
27         List files whose formatting differs from shfmt's.
28
29 -w
30         Write result to file instead of stdout.
31
32 -d
33         Error with a diff when the formatting differs.
34
35 -s
36         Simplify the code.
37
38 -f
39         Recursively find all shell files and print the paths.
40 ```
41
42 ### Examples
43
44 To list files being formatted and write directly to file
45
46 ```bash
47 shfmt -l -w <filepath>
48 ```
49
50 To show differences between shfmt formatting and original file formatting
51
52 ```bash
53 shfmt -d <filepath>
54 ```
55
56 See https://github.com/mvdan/sh for more info.