exec without -- takes --version and --help after the SDK name as vfox's own flags

Open
#824 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cli, go
Domain
cli

Research direction

Start with the custom version flag in cmd/cmd.go (around lines 49-57), which prints the version and returns nil, and then with the argument handling in cmd/commands/exec.go, where parseExecInvocation runs. Reproduce with vfox exec [email protected] etcd --version and compare it with the -- form. Done means arguments after the command name reach the command unchanged in both forms, with the -- path still working.

Written by the indexing model from the issue text.

Description

The documented form of vfox exec is vfox exec <sdk-name>[@<version>]... -- <command> [args...] (docs/usage/core-commands.md). The form without -- is accepted for one SDK, but an argument of the command that starts with a dash does not reach the command: --version prints the vfox version and the command runs without it, and --help is read as a help topic. This is the same parser problem as #808 (search), in the exec command.

Reproduction on a GitHub-hosted runner (Ubuntu 26.04.1, x86_64) with the vfox 1.1.0 release archive (checksum verified) and the zip archive of the vfox-etcd v0.2.3 tag, with etcd 3.5.12 installed by vfox exec [email protected] -- etcd --version. Run: https://github.com/version-fox/vfox-plus/actions/runs/45057624973 (the -- form also works in the earlier run https://github.com/version-fox/vfox-plus/actions/runs/45056971190)

Command Result
vfox exec [email protected] -- etcd --version etcd Version: 3.5.12, exit 0 (control)
vfox exec [email protected] etcd --version stderr 1.1.0; etcd starts with no arguments and keeps running; stopped by timeout after 30 seconds (exit 124)
vfox exec clang --version (clang not installed) stderr 1.1.0, then usage: vfox exec <sdk>[@<version>]... -- <command> [args...], exit 1
vfox exec [email protected] etcd --help stderr No help topic for '[email protected]', exit 1; etcd's help is not reached
vfox exec [email protected] etcd version passes version to etcd
vfox --version vfox version 1.1.0, exit 0

Cause: the custom cli.VersionFlag in cmd/cmd.go:49-57 prints the version and returns nil, so the command carries on. vfox still recognises the flag after the SDK name, so --version is removed before cmd/commands/exec.go:51 reads the arguments. parseExecInvocation then sees [email protected] etcd, which it reads as one SDK and the command etcd with no arguments (exec.go:82-90). For clang --version one argument is left, which gives the usage error. The -- branch avoids this, because it reads the raw arguments (exec.go:63-66).

Expected: the arguments after the command name reach the command, as they do after --. Alternatively, the form without -- refuses an argument that starts with a dash, instead of running a different command.

Possible fix: stop flag parsing at the first argument after the SDK specifications, for example with SkipFlagParsing on the exec command, reading the SDK specifications from the raw arguments as the -- branch does.

Dominant language
Go
Stars
4k
Forks
177
Avg merge
1d 20h
Merged PRs (30d)
31

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from version-fox/vfox

All issues in version-fox/vfox

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.