Fix issues #896 and #433: printf -v and arrays

This commit is contained in:
Tito Sacchi 2019-02-24 09:45:31 +01:00
parent abe6afc09f
commit bd19ab4fa9
2 changed files with 6 additions and 1 deletions

View file

@ -649,7 +649,11 @@ getModifiedVariableCommand base@(T_SimpleCommand _ _ (T_NormalWord _ (T_Literal
getPrintfVariable list = f $ map (\x -> (x, getLiteralString x)) list
where
f ((_, Just "-v") : (t, Just var) : _) = return (base, t, var, DataString $ SourceFrom list)
f ((_, Just "-v") : (t, Just var) : _) = return (base, t, varName, varType $ SourceFrom list)
where
(varName, varType) = case elemIndex '[' var of
Just i -> (take i var, DataArray)
Nothing -> (var, DataString)
f (_:rest) = f rest
f [] = fail "not found"