From be1f1c1ab76dcd55f06ecf99b585bba719bdbf5b Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Tue, 2 Jul 2019 20:58:08 -0700 Subject: [PATCH] Don't count 'readonly x' as a reference to x (fixes #1573) --- src/ShellCheck/Analytics.hs | 2 ++ src/ShellCheck/AnalyzerLib.hs | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index b2cc179..85e7afe 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -2088,6 +2088,8 @@ prop_checkUnused41= verifyNotTree checkUnusedAssignments "@test 'foo' {\ntrue\n} prop_checkUnused42= verifyNotTree checkUnusedAssignments "DEFINE_string foo '' ''; echo \"${FLAGS_foo}\"" prop_checkUnused43= verifyTree checkUnusedAssignments "DEFINE_string foo '' ''" prop_checkUnused44= verifyNotTree checkUnusedAssignments "DEFINE_string \"foo$ibar\" x y" +prop_checkUnused45= verifyTree checkUnusedAssignments "readonly foo=bar" +prop_checkUnused46= verifyTree checkUnusedAssignments "readonly foo=(bar)" checkUnusedAssignments params t = execWriter (mapM_ warnFor unused) where flow = variableFlow params diff --git a/src/ShellCheck/AnalyzerLib.hs b/src/ShellCheck/AnalyzerLib.hs index 581a117..dc0e3c4 100644 --- a/src/ShellCheck/AnalyzerLib.hs +++ b/src/ShellCheck/AnalyzerLib.hs @@ -546,10 +546,6 @@ getReferencedVariableCommand base@(T_SimpleCommand _ _ (T_NormalWord _ (T_Litera (not $ any (`elem` flags) ["f", "F"]) then concatMap getReference rest else [] - "readonly" -> - if any (`elem` flags) ["f", "p"] - then [] - else concatMap getReference rest "trap" -> case rest of head:_ -> map (\x -> (head, head, x)) $ getVariablesFromLiteralToken head