sh
sh copied to clipboard
A shell parser, formatter, and interpreter with bash support; includes shfmt
If `shfmt` is run on a file that is a symbolic link, and writes to that file, it breaks the symbolic link and replaces it with a copy of the...
Currently `Runner.writeEnv` is copied into `Runner.Vars` at the end of `Runner.Run`, but there's a comment that says `Vars` is going away. After a [Slack discussion](https://gophers.slack.com/archives/CGFNCMMDH/p1646702347351919), @mvdan suggested ```go // FinalEnv...
See https://github.com/mvdan/sh/issues/229#issuecomment-862734437. The existing https://pkg.go.dev/mvdan.cc/sh/v3/syntax#FunctionNextLine option is available via `shfmt -fn`. It works fairly well: ``` $ echo 'f() { foo; bar; }' | shfmt f() { foo bar }...
Using a three byte character: # ∞ (U+221E) (Alt + 236) I can paste or enter with no problem: ~~~ PS D:\Desktop\sh-master\cmd\gosh> .\gosh.exe $ ∞ "∞": executable file not found...
When using -bn option, only the first of the two examples below is correct. In the second case below, the binary operators are not formatted to be at the beginning...
Hi, thanks for this tool! :) I understand from #120 that zsh is not going to be supported, but the tool (tried with `3.1.0`) still wants to format them. I...
e.g., ``` #!/bin/sh curl -s http://cdn.example.com/path/to/file.tgz | tar zxf - -C /usr/src --stdout && cd /usr/src && ./configure --prefix=/usr && make install ``` => ``` #!/bin/sh curl -s http://cdn.example.com/path/to/file.tgz \...
Right now I have to keep my text editor's autoformatting code in sync with my project's Makefile to invoke `shfmt`. It would be nice to keep that version controlled on...
Given the following code: ```bash RUN_CMD=("$(foo)" \ "bar") ``` When I format it with `shfmt` I get: ```bash RUN_CMD=("$(foo)" "bar") ``` The backslash is removed at the end (which is...
We allow complex commands like `for` to be a single line, as long as their inner command also fits in a single line: ``` $ echo 'for i in 1...