Parse quoted arguments in alias expansions #90

Merged
stephen merged 1 commit from fix/alias-quoted-args into main 2026-06-08 12:14:30 +00:00
Owner

Alias expansions were tokenized with `split_whitespace`, so a quoted argument was torn apart. After `fj alias set bug 'issue create --label "needs triage"'`, running `fj bug` handed clap the tokens `--label`, `"needs`, `triage"`, so the label became `"needs` instead of `needs triage`. `gh` parses alias expansions shell-style; this brings `fj` in line.

Tokenize the expansion with `shlex` (already present in the dependency tree at 1.3.0, the advisory-fixed release; only `split` is used, never the flagged `quote`). Malformed quoting falls back to whitespace splitting so a broken alias degrades to the old behaviour rather than vanishing. Tests cover quoted, plain, and malformed expansions.

Alias expansions were tokenized with \`split_whitespace\`, so a quoted argument was torn apart. After \`fj alias set bug 'issue create --label "needs triage"'\`, running \`fj bug\` handed clap the tokens \`--label\`, \`"needs\`, \`triage"\`, so the label became \`"needs\` instead of \`needs triage\`. \`gh\` parses alias expansions shell-style; this brings \`fj\` in line. Tokenize the expansion with \`shlex\` (already present in the dependency tree at 1.3.0, the advisory-fixed release; only \`split\` is used, never the flagged \`quote\`). Malformed quoting falls back to whitespace splitting so a broken alias degrades to the old behaviour rather than vanishing. Tests cover quoted, plain, and malformed expansions.
Parse quoted arguments in alias expansions
All checks were successful
ci / check (pull_request) Successful in 10m10s
ci / live-e2e (pull_request) Successful in 1m44s
ci / coverage (pull_request) Successful in 2m7s
9bdf99d281
Alias expansions were tokenized with split_whitespace, so a quoted argument
was torn apart: `fj alias set bug 'issue create --label "needs triage"'` then
`fj bug` passed clap the three tokens --label, "needs, triage", giving a label
of '"needs' rather than 'needs triage'. gh parses aliases shell-style; fj now
does too.

Tokenize the expansion with shlex (already in the dependency tree, 1.3.0, the
advisory-fixed release; only split is used, not the flagged quote). Malformed
quoting falls back to whitespace splitting so a broken alias degrades rather
than disappears. Adds tests for quoted, plain, and malformed expansions.
Sign in to join this conversation.
No description provided.