Warn for unindented case switches
Bug #1698091 reported by
Austin English
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
bash8 |
New
|
Undecided
|
Unassigned |
Bug Description
I've got some legacy code that does:
case foo in
asdf) echo hi ;;
f) echo hi ;;
*) echo foo ;;
esac
I'd like to see a warning, as it should be:
case foo in
asdf) echo hi ;;
f) echo hi ;;
*) echo foo ;;
esac
an automated check for that would be very helpful!
To post a comment you must log in.
Alternatively, shfmt recommends maintaining the same indentation level for each pattern as the opening "case" keyword. Yes, this is a somewhat subjective choice, but as there is now a semistandard tool for styling shell script code, we might as well follow it:
https:/ /github. com/mvdan/ sh
So bashate could offer an optional setting for a case indentation preference, but should default to shfmt style so that these two powerful tools do not clash.