This article will describe using flymake-shell package which provides dynamic syntax check for shell script.
1 Install flymake-shell package
Install flymake-shell package with M-x package-list-packages.
flymake-shell 0.8 available A flymake syntax-checker for shell scripts
Add flymake-shell-load to sh-set-shell.
(add-hook 'sh-set-shell-hook 'flymake-shell-load)
3 Execution result
Invalid done is there.