Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ShellCheck/Analytics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2534,6 +2534,8 @@ prop_checkUnassignedReferences50 = verifyNotTree checkUnassignedReferences "echo
prop_checkUnassignedReferences51 = verifyNotTree checkUnassignedReferences "echo ${foo:+$foo}"
prop_checkUnassignedReferences52 = verifyNotTree checkUnassignedReferences "wait -p pid; echo $pid"
prop_checkUnassignedReferences53 = verifyTree checkUnassignedReferences "x=($foo)"
prop_checkUnassignedReferences54 = verifyNotTree checkUnassignedReferences "compgen -V files -G '*'; echo \"${files[@]}\""
prop_checkUnassignedReferences55 = verifyNotTree checkUnassignedReferences "compgen -A function -V funcs; echo \"${funcs[@]}\""

checkUnassignedReferences = checkUnassignedReferences' False
checkUnassignedReferences' includeGlobals params t = warnings
Expand Down
9 changes: 9 additions & 0 deletions src/ShellCheck/AnalyzerLib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ getModifiedVariableCommand base@(T_SimpleCommand id cmdPrefix (T_NormalWord _ (T

"mapfile" -> maybeToList $ getMapfileArray base rest
"readarray" -> maybeToList $ getMapfileArray base rest
"compgen" -> maybeToList $ getCompgenArray rest

"DEFINE_boolean" -> maybeToList $ getFlagVariable rest
"DEFINE_float" -> maybeToList $ getFlagVariable rest
Expand Down Expand Up @@ -742,6 +743,14 @@ getModifiedVariableCommand base@(T_SimpleCommand id cmdPrefix (T_NormalWord _ (T
getPrintfVariable list = getFlagAssignedVariable "v" (SourceFrom list) $ getBsdOpts "v:" list
getWaitVariable list = getFlagAssignedVariable "p" SourceInteger $ return $ getGenericOpts list

-- compgen -V arr stores the completions in the array arr rather than printing them
getCompgenArray list = do
flags <- getGnuOpts "abcdefgjksuvo:A:C:F:G:P:S:V:W:X:" list
(_, (_, value)) <- find ((== "V") . fst) flags
name <- getLiteralString value
guard $ isVariableName name
return (base, value, name, DataArray SourceExternal)

getFlagAssignedVariable str dataSource maybeFlags = do
flags <- maybeFlags
(_, (flag, value)) <- find ((== str) . fst) flags
Expand Down
Loading