mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-07 05:21:34 -07:00
Merge pull request #1824 from josephcsible/patch-1
Simplify literalEquals
This commit is contained in:
commit
6043deb8f2
1 changed files with 3 additions and 7 deletions
|
@ -3029,11 +3029,9 @@ checkArrayAssignmentIndices params root =
|
||||||
|
|
||||||
T_NormalWord _ parts ->
|
T_NormalWord _ parts ->
|
||||||
let literalEquals = do
|
let literalEquals = do
|
||||||
part <- parts
|
T_Literal id str <- parts
|
||||||
(id, str) <- case part of
|
let (before, after) = break ('=' ==) str
|
||||||
T_Literal id str -> [(id,str)]
|
guard $ all isDigit before && not (null after)
|
||||||
_ -> []
|
|
||||||
guard $ '=' `elem` str && hasNumericIndex str
|
|
||||||
return $ warnWithFix id 2191 "The = here is literal. To assign by index, use ( [index]=value ) with no spaces. To keep as literal, quote it." (surroundWidth id params "\"")
|
return $ warnWithFix id 2191 "The = here is literal. To assign by index, use ( [index]=value ) with no spaces. To keep as literal, quote it." (surroundWidth id params "\"")
|
||||||
in
|
in
|
||||||
if null literalEquals && isAssociative
|
if null literalEquals && isAssociative
|
||||||
|
@ -3041,8 +3039,6 @@ checkArrayAssignmentIndices params root =
|
||||||
else sequence_ literalEquals
|
else sequence_ literalEquals
|
||||||
|
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
where
|
|
||||||
hasNumericIndex str = all isDigit $ takeWhile (/= '=') str
|
|
||||||
|
|
||||||
|
|
||||||
prop_checkUnmatchableCases1 = verify checkUnmatchableCases "case foo in bar) true; esac"
|
prop_checkUnmatchableCases1 = verify checkUnmatchableCases "case foo in bar) true; esac"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue