Add flag to enforce ${var}
AlexSkrypnyk opened this issue · 3 comments
Can we please have an option to force ${var}
everywhere. This would be very useful for those of us who wants their scripts to be consistent.
p.s. Let's not turn this issue into a holy war about whether it is a right choice to have every variable to be wrapped in ${}
- let people decide this.
thank you
I ended up coming up with this https://github.com/AlexSkrypnyk/shell-var-lint until this issue is resolved
Enforcing it for everyone would be far too aggressive; there's nothing wrong with $var
. Remember that shfmt is a formatter, so it needs to lean towards being conservative.
It's perfectly fine for others to build a linter or more aggressive "consistency enforcer" tool on top of the same Go packages in this Go module. I personally don't have the time and resources for that.
I slipped up on the reply - you asked for an option. We want to keep the number of formatting options to a minimum, to avoid something like man indent
with its dozens of knobs. So the bar for them is pretty high - we only add an option when a large number of users would benefit, or when it helps satisfy a well known style guide like Google's.