Repository navigation
fix(err): pass the child argv through verbatim - #4206
MincongZhou wants to merge 1 commit into
Conversation
`rtk err <cmd> [args...]` joined its argv into one string and handed that to
`sh -c` / `cmd /C`, which re-split it on whitespace. A quoted argument lost its
boundary:
$ rtk err sh -c 'exit 7'
# reached sh as: sh -c exit 7
Per POSIX that runs the one-word script `exit` with `$0=7` and exits 0, so a
hard failure was reported as success.
A multi-word argv now reaches the child as a vector, the route `rtk proxy`
already takes, reusing `resolved_command` and `ChildArgExt`. A lone argument is
still a shell string, so `rtk err '<cmd> && <cmd>'` keeps composing.
Closes rtk-ai#2389
|
This overlaps with #3505, which fixes the same re-split and uses the same rule: a lone argument stays a shell string, and several arguments go straight to the child as argv. Here's how the two compare, so a reviewer doesn't have to work it out:
I don't mind which one lands. The outcomes I'd like to avoid are this merging and #2389 closing while
@MincongZhou, is either of those fine with you? |
|
Thanks for writing this out. Folding Option 2 works for me. Land this one, then rebase #3505 on top to extend the same route to On the one thing you flagged, #2389 closing while So If a maintainer would rather take #3505 whole (option 1), moving |
|
Heads-up before we go further with option 2: #4125 (pashifika) covers ryanduguid has since Windows-tested #4125 there, alongside both our PRs (#4125 (comment)). Since choosing between the lone-string rule and an explicit |
|
Closing this in favour of #4125, which KuSh merged on 2026-09-26 and which covers err, test, summary and run. Thanks @bharvey42 for flagging it, and for closing #3505 so we were not both stuck waiting. Nothing needs carrying over. The argv fix here is a subset of what landed, and the process-level tests in The one difference: this PR kept a lone quoted argument as a shell string, so |
Summary
rtk err <cmd> [args...]joined its argv into a shell string and handed that tosh -c/cmd /C, which re-split it on whitespace. A quoted argument lost its boundary, sortk err sh -c 'exit 7'was run assh -c exit 7— the one-word scriptexitwith$0=7— and exited 0. A hard failure was reported as success.rtk proxyalready takes, reusingresolved_command+ChildArgExtinstead of adding a second quoting path. A lone argument is still a shell string, sortk err '<cmd> && <cmd>'keeps composing.rtk testflattens its argv the same way incmds::rust::runner::run_test, but it already routes native expressions throughrun_passthroughand the issue isolateserr, so I left it out to keep the diff in scope. Happy to follow up separately.Closes #2389
Test plan
cargo fmt --all && cargo clippy --all-targets && cargo testrtk <command>output inspectedtests/err_argv_preservation_test.rsis new and fails on unmodifieddevelop:Manual before/after, rtk 0.48.0
develop@b748a5f, Linux x86_64. The probe prints its ownargcand each argument on stderr, then exits 1:Full
cargo test --allreports the same twoguard_integration_testfailures before and after this change (git 2.34.1 here), so they are unrelated to it.