sh icon indicating copy to clipboard operation
sh copied to clipboard

syntax: remove backslash-newline-semicolon when it's unnecessary

Open mvdan opened this issue 2 years ago • 0 comments

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

mvdan avatar Dec 20 '22 11:12 mvdan