Avoid defining flags for non-literal parameters

This commit is contained in:
Vidar Holen 2019-07-01 23:22:09 -07:00
parent 561075ea79
commit 3e3e4fd0cd
2 changed files with 5 additions and 4 deletions

View File

@ -2087,6 +2087,7 @@ prop_checkUnused40= verifyNotTree checkUnusedAssignments "arr=(1 2); num=2; echo
prop_checkUnused41= verifyNotTree checkUnusedAssignments "@test 'foo' {\ntrue\n}\n" prop_checkUnused41= verifyNotTree checkUnusedAssignments "@test 'foo' {\ntrue\n}\n"
prop_checkUnused42= verifyNotTree checkUnusedAssignments "DEFINE_string foo '' ''; echo \"${FLAGS_foo}\"" prop_checkUnused42= verifyNotTree checkUnusedAssignments "DEFINE_string foo '' ''; echo \"${FLAGS_foo}\""
prop_checkUnused43= verifyTree checkUnusedAssignments "DEFINE_string foo '' ''" prop_checkUnused43= verifyTree checkUnusedAssignments "DEFINE_string foo '' ''"
prop_checkUnused44= verifyNotTree checkUnusedAssignments "DEFINE_string \"foo$ibar\" x y"
checkUnusedAssignments params t = execWriter (mapM_ warnFor unused) checkUnusedAssignments params t = execWriter (mapM_ warnFor unused)
where where
flow = variableFlow params flow = variableFlow params

View File

@ -685,10 +685,10 @@ getModifiedVariableCommand base@(T_SimpleCommand _ _ (T_NormalWord _ (T_Literal
(filter (\(x,_) -> getLiteralString x == Just "-a") (zip (args) (tail args))) (filter (\(x,_) -> getLiteralString x == Just "-a") (zip (args) (tail args)))
-- get the FLAGS_ variable created by a shflags DEFINE_ call -- get the FLAGS_ variable created by a shflags DEFINE_ call
getFlagVariable (n:v:_) = return (base, n, flagName n, DataString $ SourceFrom [v]) getFlagVariable (n:v:_) = do
where name <- getLiteralString v
flagName varName@(T_NormalWord _ _) = "FLAGS_" ++ (onlyLiteralString varName) return (base, n, "FLAGS_" ++ name, DataString $ SourceExternal)
getFlagVariable _ = fail "Invalid flag definition" getFlagVariable _ = Nothing
getModifiedVariableCommand _ = [] getModifiedVariableCommand _ = []