Skip to content

bug: stop completion command traversal after positional input #533

Description

@codeforester

Goal

stop completion command traversal after positional input.

Background and evidence

Release-preparation review of a90aa1429647b6eb4820a01aabe37799ca55ad5e on macOS arm64. Bash 5.3.20; ordinary local POSIX filesystem.

Completion interprets a command name after positional input as a subcommand even though the runtime parser has already disabled command traversal. It suggests child-only options that the same invocation rejects.

source lib/bash/std/lib_std.sh
base_std_import cli/lib_cli.sh
base_cli_model_init demo name=demo
base_cli_positional demo '' item repeatable=true
base_cli_command demo deploy Deploy
base_cli_option demo deploy force flag --force
base_cli_complete demo -- file deploy --f
base_cli_parse demo -- file deploy --force

Completion prints --force; parsing returns 2 with unknown option '--force' and remains on the root command. In base_cli_parse, an unmatched positional sets parse_commands=0. base_cli_complete has only parse_options and continues calling the child resolver for later words.

This is separate from the now-fixed COMP_CWORD/end-of-array problems (#508 and #527).

Scope and acceptance criteria

  • Track the parser's command-traversal boundary in completion after the first positional.
  • Continue offering root/inherited options where runtime parsing still accepts them.
  • Add direct and generated-completion tests with a positional followed by a literal child name/alias, nested commands, and --.
  • Verify every suggested child-only option is reachable by the corresponding parse state.

Validation

Run CLI BATS, generated completion regression cases, and full validation.

Source references:

Non-goals

No release publication or unrelated API redesign. Preserve documented compatibility except for the defective behavior identified above.

Project fields

  • Project: base-bash-libs
  • Status: Ready
  • Priority: P2
  • Area: CLI
  • Initiative: Adoption Polish
  • Size: S
  • Milestone: v2.2.0

Agent assignment

Assignee: @codeforester. Implementation may be handled through the normal issue-backed worktree and reviewed PR workflow.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions