This question is in two parts:
- How to cause emacs linter to recognize an extglob expression as an ability instead of a syntax error?
- How to cause emacs indenter to recognize an extglob expression as a complete entry?
I have hacked and uploaded the answer to the linter half of the question. The indentation half remains unanswered.
- Using emacs 27.1.
- Editing a bash case statement which takes advantage of the extglob features.
- Modeline displays "Shell-script[bash]".
- Successfully installed flycheck and shellcheck.
I created the following code:
#!/bin/bash
shopt -s extglob
case "$1" in
-pull?(?(-)from|From)) echo pull ;;
-push?(?(-)to|To)) echo push ;;
*) >&2 echo "Did not understand ${1@Q}."
esac
$ shellcheck
finds nothing wrong the code.- Executing the bash proves proper matching. (first extglob test successfully matches -pull, -pullfrom, -pull-from, and pullFrom)
But...
sh-mode
(child ofprog-mode
), whosesh-shell
value is "bash", incorrectly indents deep after each extglob syntax.flycheck
incorrectly reports "syntax error near unexpected token `('".
How can I cause emacs to handle extglob properly?