sh
sh copied to clipboard
A shell parser, formatter, and interpreter with bash support; includes shfmt
I often use sub-shells to limit the scope of shell settings, or to preserve the cwd, and `shfmt` does a nice job of reformatting these with the proper indent --...
Hi, I was playing around with [go-task](https://github.com/go-task/task) and I couldn't get this to work: `sleep 10 & echo $!`. It would only print a new line but not the PID...
Extracting from https://github.com/mvdan/sh/issues/658#issuecomment-813054998 It would be nice to vertically align single-line case statements in a switch, to make the code condensed and more readable, especially to compare case branches more...
The point of this feature was to make using `shfmt` more reasonable for large existing codebases, which might be using custom formatting with regards to alignment or padding. For example:...
See https://github.com/mvdan/sh/pull/687#issuecomment-804102521. This should cover, for example, what makes testing these packages special, e.g. specific bash/mksh versions needed. We should also cover other aspects, taking ideas from https://github.com/burrowers/garble/blob/master/CONTRIBUTING.md.
POSIX Shell and Bash, as languages, have a few areas of ambiguity which are partially documented at https://github.com/mvdan/sh#caveats. The two main ones are: 1) Open parentheses. Is `$((` the start...
This was a case where some users were using `-kp`, particularly for PKGBUILDs. See https://github.com/mvdan/sh/issues/658#issuecomment-775143783. Copying part of the comment below. Here's an example PKGBUILD with the format: https://github.com/archlinux/svntogit-community/blob/8813db36b540577575e425ba3ce98c3894d1c768/trunk/PKGBUILD If...
A Bash arrays can start at any index, though it counts the number of set elements as part of the length. For example, Bash says: ``` $ x=([1]=a); echo ${#x[@]}...
When a switch case spans multiple lines using continuation, I think it would be good to have the begin indent for all those lines be the same, rather than increased...
https://docs.fedoraproject.org/en-US/defensive-coding/programming-languages/Shell/#sect-Defensive_Coding-Shell-Edit_Guard recommends to have `main "$@" ; exit $?` as single line… Maybe it's worth to support this case and avoid auto-rewriting it as two lines?