Skip to content

Argbash template modifies array expansion syntax and breaks script #205

@loxosceles

Description

@loxosceles

I'm using Argbash v2.11.0 to generate argument parsing code for a bash script. When I regenerate the script using the argbash template, it consistently changes this line:

In the template (working syntax):

# Command routing
case "$_arg_command" in
    # ... other cases ...
    "image_processor") cmd_run_image_processor "${_arg_leftovers[@]}" ;;
    # ... other cases ...
esac

After template application in the artifact (broken):

# Command routing
case "$_arg_command" in
    # ... other cases ...
    "image_processor") cmd_run_image_processor "${_arg_leftovers@}" ;;
    # ... other cases ...
esac

The template removes the [@] and leaves only @, which breaks the script.

More context:
My argbash template configuration:

# ARG_POSITIONAL_SINGLE([command])
# ARG_LEFTOVERS([args])
# ARG_DEFAULTS_POS([])

The _arg_leftovers array contains all arguments after the command. The function being called expects these arguments:

cmd_run_image_processor() {
    local input_path="$1"
    local args=("${@:2}")
    
    # ... path processing ...
    
    (cd image_processor && uv run python -m image_processor.cli "$input_path" "${args[@]}")
}

I need "${_arg_leftovers[@]}" to pass all the leftover arguments as separate parameters to the function so it can properly handle commands like:

script_runner.sh image_processor images/ --output processed/ --task resize --format webp

When the template changes it to "${_arg_leftovers@}", the array expansion fails and arguments aren't passed correctly to the function, breaking the image processor commands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions