Repository navigation
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1020 +/- ##
==========================================
- Coverage 93.32% 93.32% -0.01%
==========================================
Files 37 37
Lines 8423 8462 +39
Branches 424 429 +5
==========================================
+ Hits 7861 7897 +36
Misses 422 422
- Partials 140 143 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance1 warning
Comparing |
|
Commit 7645e12 has test result changes: GNU findutils testsuite: |
| } | ||
| continue; | ||
| } | ||
| let rewritten = ["-l", "-i"].iter().find_map(|&opt| { |
There was a problem hiding this comment.
what about clustered flags like -tl2 or -0iX?
with require_equals on -l, -tl2 is now read as -t -l -2, while it works on main.
please handle them and add a test
| /// attached: `-l2`, `-iX`. clap would either take the next argument as that | ||
| /// value (`xargs -l echo`) or read the attached one as more short options | ||
| /// (`-iX` as `-i -X`), so spell the attached form with `=` before parsing. | ||
| fn attach_optional_values(args: &[&str]) -> Vec<String> { |
There was a problem hiding this comment.
-e has the same problem (xargs -e echo takes echo as the eof string), could it go through the same path?
| "--max-args", | ||
| "--max-procs", | ||
| "--max-chars", | ||
| "--process-slot-var", |
There was a problem hiding this comment.
--process-slot-var isn't an option we have, is it?
| } | ||
|
|
||
| /// Short options of xargs that take their value as the next argument. | ||
| const SHORT_OPTIONS_WITH_VALUE: &[&str] = &["-a", "-d", "-E", "-I", "-L", "-n", "-P", "-s"]; |
There was a problem hiding this comment.
these lists duplicate the clap definitions and will get out of sync.
could they be derived from the Command instead?
|
|
||
| #[test] | ||
| fn optional_values_are_attached_with_equals() { | ||
| let to_vec = |args: &[&str]| attach_optional_values(args); |
There was a problem hiding this comment.
do we need this closure? :)
|
thanks for the PR! |
7645e12 to
3909709
Compare
Like GNU getopt, -l takes an optional value only when it is attached (-l2), so in `xargs -l echo` echo is the command. Mark -l require_equals and let the existing rewrite, which reads clusters such as -rl2 from the clap Command, turn -lVALUE into -l=VALUE as it does for -e.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
Commit 3909709 has test result changes: GNU findutils testsuite: |
-ltakes an optional value that GNU xargs only reads when it is attached, so the next argument is the command:Since this PR was opened, #993 added a rewrite that turns
-eVALUEinto-e=VALUEfor clap'srequire_equals. It reads clusters of short options from the clapCommandand stops at the command. So I rebuilt this PR on it:-lgetsrequire_equals, and the rewrite treats-llike-e. That drops this PR's own option lists, handles clusters such as-tl2and-rl2, and leaves-ito #1026, which extends the same rewrite to everyrequire_equalsoption.Tests:
xargs_max_lines_l_takes_only_an_attached_value:-l echo,-l2 echo,-l -r echoand the cluster-rl2 echo, checked against GNU xargs 4.11. It fails onmain.attach_eof_short_equals_rewrites_attached_max_lines: the rewrite of-l2,-tl2,-0l2and-lt, and no rewrite for-l echo, a value of-n, or the command's own-l2.cargo test --test test_xargspasses (53 tests) on Windows.AI disclosure: written with help from Claude Code.