From bca2ad4e182a212087a17a526d2bddc6bbfb951a Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 12 May 2018 17:34:23 -0700 Subject: [PATCH] Don't think declare -x -F var is used (fixes #1209). --- src/ShellCheck/Analytics.hs | 1 + src/ShellCheck/AnalyzerLib.hs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index 7a3ca0c..d73ff8e 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -1800,6 +1800,7 @@ prop_checkUnused35= verifyNotTree checkUnusedAssignments "a=foo; b=2; echo ${a:b prop_checkUnused36= verifyNotTree checkUnusedAssignments "if [[ -v foo ]]; then true; fi" prop_checkUnused37= verifyNotTree checkUnusedAssignments "fd=2; exec {fd}>&-" prop_checkUnused38= verifyTree checkUnusedAssignments "(( a=42 ))" +prop_checkUnused39= verifyNotTree checkUnusedAssignments "declare -x -f foo" checkUnusedAssignments params t = execWriter (mapM_ warnFor unused) where flow = variableFlow params diff --git a/src/ShellCheck/AnalyzerLib.hs b/src/ShellCheck/AnalyzerLib.hs index f3470b9..fc5e30b 100644 --- a/src/ShellCheck/AnalyzerLib.hs +++ b/src/ShellCheck/AnalyzerLib.hs @@ -498,7 +498,9 @@ getReferencedVariableCommand base@(T_SimpleCommand _ _ (T_NormalWord _ (T_Litera "export" -> if "f" `elem` flags then [] else concatMap getReference rest - "declare" -> if any (`elem` flags) ["x", "p"] + "declare" -> if + any (`elem` flags) ["x", "p"] && + (not $ any (`elem` flags) ["f", "F"]) then concatMap getReference rest else [] "readonly" ->