From 6d4fa9fb2c68c5fbb72c30544334634e197745dc Mon Sep 17 00:00:00 2001 From: Eisuke Kawashima Date: Fri, 19 Sep 2025 17:45:57 +0900 Subject: [PATCH] feat(SC3040): support `set -o pipefail` as specified by POSIX.1-2024 fix #2555 --- src/ShellCheck/AnalyzerLib.hs | 4 ++-- src/ShellCheck/Checks/ShellSupport.hs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ShellCheck/AnalyzerLib.hs b/src/ShellCheck/AnalyzerLib.hs index da528a4..71defa0 100644 --- a/src/ShellCheck/AnalyzerLib.hs +++ b/src/ShellCheck/AnalyzerLib.hs @@ -224,9 +224,9 @@ makeParameters spec = params hasPipefail = case shellType params of Bash -> isOptionSet "pipefail" root - Dash -> True + Dash -> isOptionSet "pipefail" root BusyboxSh -> isOptionSet "pipefail" root - Sh -> True + Sh -> isOptionSet "pipefail" root Ksh -> isOptionSet "pipefail" root, hasExecfail = case shellType params of diff --git a/src/ShellCheck/Checks/ShellSupport.hs b/src/ShellCheck/Checks/ShellSupport.hs index b664879..4ce4fa8 100644 --- a/src/ShellCheck/Checks/ShellSupport.hs +++ b/src/ShellCheck/Checks/ShellSupport.hs @@ -175,7 +175,7 @@ prop_checkBashisms80 = verifyNot checkBashisms "#!/bin/sh\nhash -r" prop_checkBashisms81 = verifyNot checkBashisms "#!/bin/dash\nhash -v" prop_checkBashisms82 = verifyNot checkBashisms "#!/bin/sh\nset -v +o allexport -o errexit -C" prop_checkBashisms83 = verifyNot checkBashisms "#!/bin/sh\nset --" -prop_checkBashisms84 = verify checkBashisms "#!/bin/sh\nset -o pipefail" +prop_checkBashisms84 = verifyNot checkBashisms "#!/bin/sh\nset -o pipefail" prop_checkBashisms85 = verify checkBashisms "#!/bin/sh\nset -B" prop_checkBashisms86 = verifyNot checkBashisms "#!/bin/dash\nset -o emacs" prop_checkBashisms87 = verify checkBashisms "#!/bin/sh\nset -o emacs" @@ -383,8 +383,8 @@ checkBashisms = ForShell [Sh, Dash, BusyboxSh] $ \t -> do beginsWithDoubleDash = (`matches` mkRegex "^--.+$") longOptions = Set.fromList [ "allexport", "errexit", "ignoreeof", "monitor", "noclobber" - , "noexec", "noglob", "nolog", "notify" , "nounset", "verbose" - , "vi", "xtrace" ] + , "noexec", "noglob", "nolog", "notify" , "nounset", "pipefail" + , "verbose", "vi", "xtrace" ] bashism t@(T_SimpleCommand id _ (cmd:rest)) = let name = fromMaybe "" $ getCommandName t