Repository navigation
xargs: keep empty items with -0 and -d - #894
SichenLiang wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #894 +/- ##
==========================================
+ Coverage 92.27% 92.29% +0.01%
==========================================
Files 35 35
Lines 7576 7590 +14
Branches 393 394 +1
==========================================
+ Hits 6991 7005 +14
Misses 443 443
Partials 142 142 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Commit 6243028 has test result changes: bfs testsuite: |
| let mut args: Box<dyn ArgumentReader> = if let Some(delimiter) = options.delimiter { | ||
| Box::new(ByteDelimitedArgumentReader::new(args_file, delimiter)) | ||
| let mut reader = ByteDelimitedArgumentReader::new(args_file, delimiter); | ||
| reader.keep_empty = options.null || matches.contains_id(options::DELIMITER); |
There was a problem hiding this comment.
could keep_empty be a parameter of new() instead of setting the field afterwards?
it would also be nicer to compute it once when the delimiter is resolved, rather than checking matches again here
There was a problem hiding this comment.
Done. keep_empty is now passed to ByteDelimitedArgumentReader::new() and computed once in normalize_options, after the delimiter is resolved. do_xargs no longer checks matches here.
The flag is still needed because -I by itself also uses this reader with a newline delimiter, and GNU skips empty lines in that case.
The byte-delimited reader discarded empty records. Keep them so -0 and -d pass empty input items to the command, as GNU xargs does. Leave the default whitespace parser unchanged and add coverage for empty records with -r, -n and -I.
6243028 to
c19fd7d
Compare
|
Commit c19fd7d has test result changes: bfs testsuite: |
|
sorry but it needs to be rebased |
xargs -0andxargs -ddropped empty items at the beginning, middle, or end of the input. GNU passes each empty item to the command.Keep empty records in the byte-delimited reader. The default whitespace parser is unchanged, so blank input lines still do not become empty arguments.
This also makes the existing item-based options see the empty records:
-n,-L,-s, and-Inow count or substitute them, and-rstill suppresses a command only when there are no input items at all.Tests cover NUL and explicit delimiters, empty items in each position, their interaction with
-r,-n, and-I, and the reader itself.Fixes #889