anordal / shellharden

The corrective bash syntax highlighter
Mozilla Public License 2.0
4.62k stars 129 forks source link

Nested case statement are mangled #37

Closed zhelezov closed 3 years ago

zhelezov commented 3 years ago

Hi, I just found that shellharden has some difficulties with nested case statements like in this example input:

e=0
case $i in
  a) : this ;;
  b) : that ;;
  *)
    case $i in
      c) j=3 ;;
      d) j=2 ;;
      *) e=1 ;;
    esac
    : use j
    ;;
esac
: use e

I get this unexpected diff transform:

@@ -7,7 +7,7 @@
       c) j=3 ;;
       d) j=2 ;;
       *) e=1 ;;
-    esac
+    ;; esac
     : use j
     ;;
 esac
anordal commented 3 years ago

Fixed in 90d5b43, with test added.

Thank you!