In shell scripts, case branches traditionally end with ;;. Bash additionally supports case branches ending with ;& and ;;&. Zsh similarly supports case branches ending with ;& and ;|. Currently sh-script.el supports case branches ending with ;;, ;&, and ;;&, but not with ;|. The attached patch adds support for case branches ending with ;|.
I have tested the patch by defining all the modified functions (sh-smie-sh-rules, sh-font-lock-paren) and constants (sh-smie-sh-grammar, sh-smie-rc-grammar, sh-smie--sh-operators, sh-smie--sh-operators-re, sh-smie--sh-operators-back-re) in my .emacs (in a (with-eval-after-load 'sh-script ...) statement).
Here is an example indented without the patch:
case $input in
*a* ) echo A;;
*b* ) echo B;&
*c* ) echo C;;&
*d* ) echo D;|
*e* ) echo E;;
esac
and with the (simulated) patch:
case $input in
*a* ) echo A;;
*b* ) echo B;&
*c* ) echo C;;&
*d* ) echo D;|
*e* ) echo E;;
esac
The first change in the patch replaces an
(eq (char-before) ?|) with (and (eq (char-before) ?|) (not (eq (char-before (1- (point))) ?\;))). It is needed to avoid confusing ;| tokens with plain | tokens. I wonder however whether there would be a cleaner way of expressing the same.
The second change replaces a
(looking-at ";[;&]\\|\\_<in") with (looking-at ";\\(?:;&?\\|[&|]\\)\\|\\_<in"). The original _expression_ is looking for ;; and ;& tokens but not for ;;& tokens, which looks like an oversight to me. That's why I have changed it to look for ;;, ;&, ;| but also ;;&.
The other changes simply add support for ;| where there was previously support for ;;, ;&, and ;;&.
Philippe