fix(nushell): strip surrounding quotes from --flag="value" tokens#2437
fix(nushell): strip surrounding quotes from --flag="value" tokens#2437worktrunk-bot wants to merge 2 commits intomainfrom
Conversation
Nushell's `def --wrapped` re-tokenizes the space-separated form (`--flag "value"` → ["--flag", "value"]) but keeps the equals form as a single literal token (`--flag="value"` → ['--flag="value"']), so the worktrunk binary received the quote characters in argv and clap parsed them as part of the value. Fixes #2410. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
test (linux) and code-coverage both failed at the |
|
CI failures (
|
|
But surely there's something we're doing wrong in our wrapper, rather than needing to regex strip string args?? We want a simple implementation that does as little as possible; can we review this behavior? |
|
Fair pushback — let me lay out what I checked, because the answer landed on "the strip is doing real work, but you may prefer to skip the fix entirely." Why bash/zsh/fish don't need this and nushell does. In POSIX shells, the function never sees the quotes — the shell tokenises Calling python3 directly (no What I considered as alternatives, and why I landed on the strip:
The "do less" path that actually exists. Drop the strip and document the limitation: tell nushell users that the supported forms are I'm happy either way — close this PR and I'll send a tiny doc/FAQ note instead, or land it as-is. (One small tightening if we keep it: the regex's closing-quote class doesn't backreference the opening quote, so |
|
so in general, CLI apps don't support nushell with |
|
No — The bug is specific to commands invoked through a We need the wrapper because of the cd/exec directive files (so
Given that, the choices are still the two from before:
Happy to go either way; let me know which you'd prefer. |
Summary
Fixes #2410. Nushell's
def --wrappedre-tokenizes--flag "value"into two tokens but keeps--flag="value"as a single literal token (with the surrounding quote characters), so the worktrunk binary received argv like--base="releases/4.x.x"and clap parsed the quotes as part of the value. Strip matching surrounding"/'from--flag=…/-x=…tokens before forwarding...$args.What changed
templates/nushell.nu— one-passeachover$argsrunningstr replace -r '^(-{1,2}[^=]+)=(["''])(.*)["'']$' '${1}=${3}'before the binary is invoked.tests/integration_tests/shell_wrapper.rs— addstest_wrapper_nu_strips_quoted_equals_flag, an end-to-end test that creates areleases/4.x.xbranch, runswt switch -c feature --base="releases/4.x.x"through the actual nu wrapper via PTY, and asserts the worktree is created. Verified the test fails onmain(without the template change) and passes with it.src/shell/snapshots/worktrunk__shell__tests__init_nu.snap— refreshed for the new wrapper lines.Forms exercised
Verified by hand against a real
wt config shell init nuinstall on nushell 0.112.2:--base "releases/4.x.x"--base releases/4.x.x--base=releases/4.x.x--base="releases/4.x.x"--base='releases/4.x.x'-b="releases/4.x.x"Test plan
cargo run -- hook pre-merge --yespasses locally (3377/3377 tests; lychee unavailable in this env, CI will run it)🤖 Generated with Claude Code