bash_minifier
bash_minifier copied to clipboard
Does not minify case statements well.
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 ;;.