From 1863f2f12d810799a9de0bb0f01d2803aa74b92e Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 14 Jan 2017 12:40:09 -0800 Subject: [PATCH] Warn about += bashism in sh and dash. --- ShellCheck/Checks/ShellSupport.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ShellCheck/Checks/ShellSupport.hs b/ShellCheck/Checks/ShellSupport.hs index 6c66e50..d7d3a3a 100644 --- a/ShellCheck/Checks/ShellSupport.hs +++ b/ShellCheck/Checks/ShellSupport.hs @@ -134,6 +134,7 @@ prop_checkBashisms50= verify checkBashisms "#!/bin/sh\ncmd >& file" prop_checkBashisms51= verifyNot checkBashisms "#!/bin/sh\ncmd 2>&1" prop_checkBashisms52= verifyNot checkBashisms "#!/bin/sh\ncmd >&2" prop_checkBashisms53= verifyNot checkBashisms "#!/bin/sh\nprintf -- -f\n" +prop_checkBashisms54= verify checkBashisms "#!/bin/sh\nfoo+=bar" checkBashisms = ForShell [Sh, Dash] $ \t -> do params <- ask kludge params t @@ -174,6 +175,8 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do bashism (T_FdRedirect id ('{':_) _) = warnMsg id "named file descriptors are" bashism (T_FdRedirect id num _) | all isDigit num && length num > 1 = warnMsg id "FDs outside 0-9 are" + bashism (T_Assignment id Append _ _ _) = + warnMsg id "+= is" bashism (T_IoFile id _ word) | isNetworked = warnMsg id "/dev/{tcp,udp} is" where