mirror of
https://github.com/koalaman/shellcheck
synced 2025-08-22 22:33:51 -07:00
Merge 4908d52236
into 868a7be33e
This commit is contained in:
commit
86662b0d16
1 changed files with 11 additions and 2 deletions
|
@ -1879,6 +1879,8 @@ prop_checkUnassignedReferences32= verifyNotTree checkUnassignedReferences "if [[
|
||||||
prop_checkUnassignedReferences33= verifyNotTree checkUnassignedReferences "f() { local -A foo; echo \"${foo[@]}\"; }"
|
prop_checkUnassignedReferences33= verifyNotTree checkUnassignedReferences "f() { local -A foo; echo \"${foo[@]}\"; }"
|
||||||
prop_checkUnassignedReferences34= verifyNotTree checkUnassignedReferences "declare -A foo; (( foo[bar] ))"
|
prop_checkUnassignedReferences34= verifyNotTree checkUnassignedReferences "declare -A foo; (( foo[bar] ))"
|
||||||
prop_checkUnassignedReferences35= verifyNotTree checkUnassignedReferences "echo ${arr[foo-bar]:?fail}"
|
prop_checkUnassignedReferences35= verifyNotTree checkUnassignedReferences "echo ${arr[foo-bar]:?fail}"
|
||||||
|
prop_checkUnassignedReferences36= verifyTree checkUnassignedReferences "#!/bin/ksh\necho \"${GLOBAL}\"\n"
|
||||||
|
prop_checkUnassignedReferences37= verifyNotTree checkUnassignedReferences "#!/bin/ksh\necho \"$1\"\n"
|
||||||
checkUnassignedReferences params t = warnings
|
checkUnassignedReferences params t = warnings
|
||||||
where
|
where
|
||||||
(readMap, writeMap) = execState (mapM tally $ variableFlow params) (Map.empty, Map.empty)
|
(readMap, writeMap) = execState (mapM tally $ variableFlow params) (Map.empty, Map.empty)
|
||||||
|
@ -1908,9 +1910,16 @@ checkUnassignedReferences params t = warnings
|
||||||
isLocal = any isLower
|
isLocal = any isLower
|
||||||
|
|
||||||
warningForGlobals var place = do
|
warningForGlobals var place = do
|
||||||
match <- getBestMatch var
|
isNotSpecialVars var
|
||||||
return $ warn (getId place) 2153 $
|
return $ warn (getId place) 2153 $
|
||||||
"Possible misspelling: " ++ var ++ " may not be assigned, but " ++ match ++ " is."
|
case getBestMatch var of
|
||||||
|
Just match -> "Possible misspelling: " ++ var ++ " may not be assigned, but " ++ match ++ " is."
|
||||||
|
Nothing -> "Possible misspelling: " ++ var ++ " may not be assigned."
|
||||||
|
where
|
||||||
|
isNotSpecialVars [] = Nothing
|
||||||
|
isNotSpecialVars (a:_) | isNumber a = Nothing
|
||||||
|
| any (== a) "$#@?!" = Nothing
|
||||||
|
| otherwise = return ()
|
||||||
|
|
||||||
warningForLocals var place =
|
warningForLocals var place =
|
||||||
return $ warn (getId place) 2154 $
|
return $ warn (getId place) 2154 $
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue