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

Aperta
#824 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cli, go
Ambito
cli

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Go
Stelle
4k
Fork
177
Merge medio
1g 20h
PR unite (30g)
31

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di version-fox/vfox

Tutte le issue di version-fox/vfox

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.