Skip to main content
Skip to main content

AG008: Duplicate Flag Name

PropertyValue
CodeAG008
SeverityWarning
Sincev0.1.0

Description

Two or more entries in the same args=() array declare the same long flag name. This means only one of them will take effect at parse time, which is almost always a bug.

The duplicate check is suppressed when the :^ (inherited) modifier is involved, since inherited fields intentionally override parent definitions.

Example

This triggers AG008:

my_func() {
local domain
local -a args=(
'domain|d' "The domain name"
'domain|' "The domain (duplicate)"
)
:args "Test" "${@}"
}

How to Fix

Remove the duplicate entry or rename one of the flags:

my_func() {
local domain
local -a args=(
'domain|d' "The domain name"
)
:args "Test" "${@}"
}

How to Suppress

# argsh disable=AG008
'domain|' "The domain (duplicate)"

Or file-wide:

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