mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
7.21k stars 339 forks source link

syntax: fix two bugs when formatting case clauses #952

Closed mvdan closed 1 year ago

mvdan commented 1 year ago

(see commit messages - please do not squash)

Fixes #779. Fixes #917.

cc @ainar-g @Julien-Elie @zx8 @DannyBen if you want to test this out

DannyBen commented 1 year ago

Want. But I am only using the binary. I will try to build me a small Docker with it for testing.

DannyBen commented 1 year ago

Beautiful.

I can confirm this branch works as expected for me. Tested with the test.sh file mentioned in #950

➜ shfmt -d -i 2 -ci test.sh

--- test.sh.orig
+++ test.sh
@@ -3,8 +3,7 @@
 action=download

 case $action in
-  -*)
-    ;;
+  -*) ;;

   upload)
     # This upload section is being messed up with a weird backslash
ainar-g commented 1 year ago

I can confirm that the issue with case's is fixed. (I seem to have found another issue, but that one seems to be unrelated to this PR, and I'll file it separately.) Thanks!