Merge pull request #1445 from Gandalf-/issue_1318_single_comma_array

Issue 1318 single comma array delimiter
This commit is contained in:
Vidar Holen 2019-01-09 17:42:35 -08:00 committed by GitHub
commit e45b679d58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -1251,6 +1251,7 @@ prop_checkCommarrays3 = verifyNot checkCommarrays "cow=(1 \"foo,bar\" 3)"
prop_checkCommarrays4 = verifyNot checkCommarrays "cow=('one,' 'two')" prop_checkCommarrays4 = verifyNot checkCommarrays "cow=('one,' 'two')"
prop_checkCommarrays5 = verify checkCommarrays "a=([a]=b, [c]=d)" prop_checkCommarrays5 = verify checkCommarrays "a=([a]=b, [c]=d)"
prop_checkCommarrays6 = verify checkCommarrays "a=([a]=b,[c]=d,[e]=f)" prop_checkCommarrays6 = verify checkCommarrays "a=([a]=b,[c]=d,[e]=f)"
prop_checkCommarrays7 = verify checkCommarrays "a=(1,2)"
checkCommarrays _ (T_Array id l) = checkCommarrays _ (T_Array id l) =
when (any (isCommaSeparated . literal) l) $ when (any (isCommaSeparated . literal) l) $
warn id 2054 "Use spaces, not commas, to separate array elements." warn id 2054 "Use spaces, not commas, to separate array elements."
@ -1258,9 +1259,9 @@ checkCommarrays _ (T_Array id l) =
literal (T_IndexedElement _ _ l) = literal l literal (T_IndexedElement _ _ l) = literal l
literal (T_NormalWord _ l) = concatMap literal l literal (T_NormalWord _ l) = concatMap literal l
literal (T_Literal _ str) = str literal (T_Literal _ str) = str
literal _ = "str" literal _ = ""
isCommaSeparated str = "," `isSuffixOf` str || length (filter (== ',') str) > 1 isCommaSeparated = elem ','
checkCommarrays _ _ = return () checkCommarrays _ _ = return ()
prop_checkOrNeq1 = verify checkOrNeq "if [[ $lol -ne cow || $lol -ne foo ]]; then echo foo; fi" prop_checkOrNeq1 = verify checkOrNeq "if [[ $lol -ne cow || $lol -ne foo ]]; then echo foo; fi"