xargs: empty items are dropped with -0 and -d
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start by locating the xargs implementation and its handling of -0 and -d byte-delimited input. Reproduce the commands in this report, then trace how delimiters at the beginning or next to another delimiter are parsed. Done means empty items reach the command, including with -n1 and -r, while non-byte-delimited behavior remains unchanged.
Written by the indexing model from the issue text.
Description
With -0 or -d, uutils xargs drops an empty input item when a delimiter appears at the start of the input or immediately after another delimiter.
$ printf 'a\0\0b\0' | xargs -0 printf '[%s]\n'
[a]
[b]
GNU findutils 4.11.0 passes the empty item to the command:
[a]
[]
[b]
The same problem occurs with explicit delimiters, including:
printf 'a,,b,' | xargs -d, printf '[%s]\n'
printf 'a\n\nb\n' | xargs -d '\n' printf '[%s]\n'
Dropping the item also changes the behavior of options that count arguments. For example, GNU runs test -n '' here and exits 123, while uutils skips that invocation and exits 0:
printf 'a\0\0b\0' | xargs -0 -n1 test -n
Likewise, printf '\0' | xargs -0 -r printf '[%s]\n' prints [] with GNU but runs nothing with uutils.
This is specific to byte-delimited input. Without -0 or -d, empty lines do not become empty arguments.
Tested on Linux x86_64 against GNU findutils 4.11.0.
- Dominant language
- Rust
- Stars
- 651
- Forks
- 111
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 21
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from uutils/findutils
-
-printf %m and -ls drop setuid/setgid/sticky bits and the file typePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
uutils/findutils#692 · 1 comment ·
Maintainers usually reply within 1 day
-
find on Windows: opt in to / as the path separatorPossibly taken @mutewinter claimed this 4 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 15/100
Maintainers usually reply within 1 day
-
xargs: -x runs a pending command before rejecting an oversized argumentPossibly taken @SichenLiang claimed this 6 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 28/100
Maintainers usually reply within 1 day
-
find: -ls shows the time instead of the year for old filesPossibly taken @SichenLiang claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 32/100
Maintainers usually reply within 1 day
All issues in uutils/findutils
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
home-assistant/installer#308 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
swc-project/swc-next#1053 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nautechsystems/nautilus_trader#5387 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
NomicFoundation/edr#1872 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
linebender/resvg#1179 · 1 comment ·
Maintainers usually reply within 2 days