sh icon indicating copy to clipboard operation
sh copied to clipboard

how to leave one-line subshells as they are

Open Karmenzind opened this issue 5 months ago • 0 comments

shfmt will change some simple one-line subshell expressions into multi lines, which is unnecessary for me:

$ shfmt -d /tmp/a.sh
diff /tmp/a.sh.orig /tmp/a.sh
--- /tmp/a.sh.orig
+++ /tmp/a.sh
@@ -1,8 +1,11 @@
 #!/usr/bin/env bash
 # vim:set et sw=4 ts=4:
-CURDIR=$(cd `dirname $0`; pwd)
+CURDIR=$(
+       cd $(dirname $0)
+       pwd
+)

Could you please add a configuration option like keep_oneline_subshell = true, or simply provide a comment tag like # @shfmt-ignore?

Karmenzind avatar Aug 28 '24 08:08 Karmenzind