Skip to content

xargs: attach short values for every require_equals option - #1026

Open
emirmrkaljevic wants to merge 2 commits into
uutils:mainfrom
emirmrkaljevic:xargs-replace-require-equals
Open

emirmrkaljevic wants to merge 2 commits into
uutils:mainfrom
emirmrkaljevic:xargs-replace-require-equals

Conversation

@emirmrkaljevic

@emirmrkaljevic emirmrkaljevic commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #993.

As suggested in review there, the attached-value rewrite now checks option.is_require_equals_set() instead of the -e id. So -i gets the same treatment: -i_ is rewritten to -i=_ and works, instead of failing because clap reads the attached value as more short options.

This also makes -i={} match GNU, where everything after -i is the replace string, including the =:

$ echo foo | xargs -i={} echo {} bar
{} bar

The xargs_replace test expected foo bar there, so I updated it to the GNU output, added a ={} bar case that does get replaced, and switched the other -i=_ cases to -i_. I checked the outputs against GNU xargs 4.10.0. #1020 also rewrites -iX, but keeps -i=X as X.

I found this with behave (https://github.com/emirmrkaljevic/behave).

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.43%. Comparing base (48e10b3) to head (3fabdb9).

Files with missing lines Patch % Lines
src/xargs/mod.rs 90.90% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1026      +/-   ##
==========================================
- Coverage   92.44%   92.43%   -0.01%     
==========================================
  Files          38       38              
  Lines        8896     8901       +5     
  Branches      440      440              
==========================================
+ Hits         8224     8228       +4     
  Misses        532      532              
- Partials      140      141       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Commit abf3453 has test result changes:

GNU findutils testsuite:

Test results comparison:
  Current:   TOTAL: 495 / PASSED: 467 / FAILED: 27 / SKIPPED: 1
  Reference: TOTAL: 495 / PASSED: 464 / FAILED: 30 / SKIPPED: 1

Changes from main branch:
  TOTAL: +0
  PASSED: +3
  FAILED: -3

Test improvements (3):
  + iARG
  + iquotes
  + savannah-11865

@codspeed

codspeed Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 15 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 20 untouched benchmarks


Comparing emirmrkaljevic:xargs-replace-require-equals (3fabdb9) with main (48e10b3)

Open in CodSpeed

Comment thread src/xargs/mod.rs
None => continue,
Some(true) => next_is_value = value.is_empty(),
Some(false) => {
if option.is_require_equals_set() && !value.is_empty() {

@sylvestre sylvestre Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-l also takes an optional attached value but has no require_equals, so xargs -l echo probably takes echo as its value.
should it get the same treatment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch. xargs -l echo failed with "invalid value 'echo'" while GNU runs echo with one line per command. In 9defd43 -l gets require_equals too, so -l2 still works, -l echo treats echo as the command, and -l=2 is rejected as an invalid number like GNU. Added xargs_max_lines_l_value_must_be_attached.

@sylvestre

Copy link
Copy Markdown
Contributor

sorry but it needs to be rebased

@emirmrkaljevic
emirmrkaljevic force-pushed the xargs-replace-require-equals branch from 9defd43 to c48b626 Compare November 25, 2026 07:30
@emirmrkaljevic

Copy link
Copy Markdown
Contributor Author

Rebased on main now that #993 is merged, so only the two commits for this PR are left. The -l conflict was just the new default_missing_value line, I kept both. xargs tests pass locally.

@github-actions

Copy link
Copy Markdown

Commit c48b626 has test result changes:

GNU findutils testsuite:

Test results comparison:
  Current:   TOTAL: 508 / PASSED: 474 / FAILED: 30 / SKIPPED: 4
  Reference: TOTAL: 508 / PASSED: 471 / FAILED: 33 / SKIPPED: 4

Changes from main branch:
  TOTAL: +0
  PASSED: +3
  FAILED: -3

Test improvements (3):
  + iARG
  + iquotes
  + savannah-11865

Check is_require_equals_set() instead of the -e id, so -iVALUE is
rewritten to -i=VALUE too. Like GNU, -i={} now uses '={}' as the
replace string.
@sylvestre
sylvestre force-pushed the xargs-replace-require-equals branch from c48b626 to 3fabdb9 Compare November 29, 2026 14:48
@github-actions

Copy link
Copy Markdown

Commit 3fabdb9 has test result changes:

GNU findutils testsuite:

Test results comparison:
  Current:   TOTAL: 508 / PASSED: 478 / FAILED: 26 / SKIPPED: 4
  Reference: TOTAL: 508 / PASSED: 475 / FAILED: 29 / SKIPPED: 4

Changes from main branch:
  TOTAL: +0
  PASSED: +3
  FAILED: -3

Test improvements (3):
  + iARG
  + iquotes
  + savannah-11865

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants