Fix uninitialized wrapped script arrays causing shellcheck failures #207
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix uninitialized wrapped script arrays causing shellcheck failures
When ARGBASH_WRAP is used, the code generator creates combined arrays
that reference both _opt and _pos suffixed arrays for each wrapped
script group:
However, if a wrapped script only had positional arguments OR only
optional arguments, one of these arrays would never be initialized,
causing shellcheck SC2154 warnings ('variable referenced but not
assigned') and test failures.
This commit fixes the issue by:
Initializing both _opt and _pos arrays as empty arrays for ALL
wrapped script groups during the defaults initialization phase.
This is done in both _MAKE_DEFAULTS_POSITIONAL and
_MAKE_DEFAULTS_OPTIONAL to ensure coverage regardless of which
argument types the script has.
Adding a shellcheck disable directive (SC2154) in the generated
assign_positional_args function where wrapped positional arrays
reference variables like $_arg_pos_arg. These variables ARE
assigned via eval, but shellcheck cannot trace dynamic assignments:
The disable directive prevents false positive warnings while
keeping shellcheck validation for the rest of the generated code.
Fixes shellcheck errors in scripts using ARGBASH_WRAP such as:
Assisted-by: Claude 4.5 Opus
Signed-off-by: Stephen Gallagher sgallagh@redhat.com