sh
sh copied to clipboard
syntax: remove backslash-newline-semicolon when it's unnecessary
Take this piece of shell:
$ cat f.sh
if
true \
; then
echo yes
fi
$ bash f.sh
yes
$ shfmt f.sh
if
true \
;
then
echo yes
fi
Note how it runs, but shfmt didn't improve it that much. It could do better, instead producing:
$ cat f2.sh
if
true
then
echo yes
fi
$ bash f2.sh
yes
$ shfmt f2.sh
if
true
then
echo yes
fi