ShellCheck/138080bd.patch
2019-05-18 12:06:46 +02:00

36 lines
1.4 KiB
Diff

From 138080bdc7442458f45bd2726d9e8cb4b68cf24f Mon Sep 17 00:00:00 2001
From: Vidar Holen <spam@vidarholen.net>
Date: Sun, 16 Dec 2018 14:42:19 -0800
Subject: [PATCH] Fix infinite loop on annotations for SC2188 (fixes #1413)
---
src/ShellCheck/Analytics.hs | 2 +-
src/ShellCheck/Checker.hs | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs
index 7754ee64..a164de13 100644
--- a/src/ShellCheck/Analytics.hs
+++ b/src/ShellCheck/Analytics.hs
@@ -2692,7 +2692,7 @@ checkRedirectedNowhere params token =
case drop 1 $ getPath (parentMap params) t of
T_DollarExpansion _ [_] : _ -> True
T_Backticked _ [_] : _ -> True
- T_Annotation _ _ u : _ -> isInExpansion u
+ t@T_Annotation {} : _ -> isInExpansion t
_ -> False
getDanglingRedirect token =
case token of
diff --git a/src/ShellCheck/Checker.hs b/src/ShellCheck/Checker.hs
index 7ac9c913..10074e38 100644
--- a/src/ShellCheck/Checker.hs
+++ b/src/ShellCheck/Checker.hs
@@ -231,5 +231,7 @@ prop_filewideAnnotation8 = null $
prop_sourcePartOfOriginalScript = -- #1181: -x disabled posix warning for 'source'
2039 `elem` checkWithIncludes [("./saywhat.sh", "echo foo")] "#!/bin/sh\nsource ./saywhat.sh"
+prop_spinBug1413 = null $ check "fun() {\n# shellcheck disable=SC2188\n> /dev/null\n}\n"
+
return []
runTests = $quickCheckAll