From a669e1684b7502c625045d551cbf4e7560390e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Adri=C3=A1n=20Ontivero?= Date: Sun, 27 Jan 2019 08:22:37 +0100 Subject: [PATCH] Check hash flags under dash and POSIX sh Flags for the hash builtin other than [-r] are undefined under POSIX sh. Dash also accepts [-v], while bash adds [-l] [-p filename] [-dt] aside from [-r]. --- src/ShellCheck/Checks/ShellSupport.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ShellCheck/Checks/ShellSupport.hs b/src/ShellCheck/Checks/ShellSupport.hs index 5a164d8..54af521 100644 --- a/src/ShellCheck/Checks/ShellSupport.hs +++ b/src/ShellCheck/Checks/ShellSupport.hs @@ -158,6 +158,9 @@ prop_checkBashisms75 = verifyNot checkBashisms "#!/bin/sh\necho \"-n foo\"" prop_checkBashisms76 = verifyNot checkBashisms "#!/bin/sh\necho \"-ne foo\"" prop_checkBashisms77 = verifyNot checkBashisms "#!/bin/sh\necho -Q foo" prop_checkBashisms78 = verify checkBashisms "#!/bin/sh\necho -ne foo" +prop_checkBashisms79 = verify checkBashisms "#!/bin/sh\nhash -l" +prop_checkBashisms80 = verifyNot checkBashisms "#!/bin/sh\nhash -r" +prop_checkBashisms81 = verifyNot checkBashisms "#!/bin/dash\nhash -v" checkBashisms = ForShell [Sh, Dash] $ \t -> do params <- ask kludge params t @@ -307,6 +310,7 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do ("cd", Just ["L", "P"]), ("exec", Just []), ("export", Just ["p"]), + ("hash", Just $ if isDash then ["r", "v"] else ["r"]), ("jobs", Just ["l", "p"]), ("printf", Just []), ("read", Just $ if isDash then ["r", "p"] else ["r"]),