bash_minifier icon indicating copy to clipboard operation
bash_minifier copied to clipboard

Does not minify case statements well.

Open fidian opened this issue 8 years ago • 0 comments

Input script:

#!/usr/bin/env bash
case "$PATH" in
    thing)
        echo "Shouldn't match this."
        ;;
esac

Resulting minified code:

case "$PATH" in thing);echo "Shouldn't match this.";;;esac

Bash's error:

bash: test.min: line 1: syntax error near unexpected token `;'
bash: test.min: line 1: `case "$PATH" in thing);echo "Shouldn't match this.";;;esac'

There shouldn't be a semicolon after the close parenthesis. Also, the three ;;; in a row cause a problem. Here's the fixed version:

case "$PATH" in thing) echo "Shouldn't match this." ;; esac

Also, you might need to treat ;& and ;;& because they parse similarly to ;;.

fidian avatar Jul 31 '17 13:07 fidian