-
-
Notifications
You must be signed in to change notification settings - Fork 381
Description
I was trying to find a tool that automates removing unnecessary semicolon use in shell scripts, and stumbled upon shfmt. It is really cool, but the exact feature I need does not exist, hence this feature request for your consideration.
The canonical.sh in this example:
for foo in a b c; do
bar
done
However I prefer for better readability to avoid extra semicolons and just use separate lines as by design in Bash:
for foo in a b c
do
bar
done
I know also the Google style guide prefers this:
if ! do_something; then
err "Unable to do_something"
exit 1
fi
However I find it cleaner to write:
if ! do_something
then
err "Unable to do_something"
exit 1
fi
Use of extra ; is common in if, for and while clauses.
Following existing --binary-next-line and --func-next-line this feature could maybe be invoked with something ..next-line or it could be called simply --no-extra-semicolon.
I see that in #229 (comment) and #721 there was plans to have this functionality combined with putting function { } on separate lines. I don't mind if functions are on separate lines or not, I just don't want to have my source cluttered with extra semicolons in an attempt to inline something that has plenty of space to be on its own line.
This flag to not use extra semicolons would potentially also close #959 and #1210.