Skip to main content
Skip to main content

AG010: Command Resolves to Bare Function

PropertyValue
CodeAG010
SeverityWarning
Sincev0.1.0

Description

A usage=() entry resolves to a bare (non-namespaced) function instead of a properly namespaced one like main::deploy(). While this works at runtime, bare function names are more likely to collide with other functions or external commands.

This diagnostic only fires when the namespaced form does not exist but a bare function with the same name does.

Example

This triggers AG010:

main() {
local -a usage=(
"deploy" "Deploy the app"
)
:usage "My CLI" "${@}"
}

# Bare function -- works but risks collision
deploy() {
echo "Deploying..."
}

How to Fix

Rename the function to use the namespace prefix:

main() {
local -a usage=(
"deploy" "Deploy the app"
)
:usage "My CLI" "${@}"
}

main::deploy() {
echo "Deploying..."
}

How to Suppress

# argsh disable=AG010
"deploy" "Deploy the app"

Or file-wide:

# argsh disable-file=AG010
Was this section helpful?