-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xargs: stdin should not be merged before replacing #362
Comments
I am curious why you are sharing a python example ? :) would you like to try to provide a fix? |
I thought it was caused by CR/LF or shells, so I want to feed bytes to the executable directly. AFAIK, python is the easiest way.
I'd like to do so! But I cannot guarantee when, maybe in a month? |
I've inspected it deeper. The issue is harder than I thought. The command is always executed once in current implementation, but it needs to be executed multiple times if Example: # xargs (GNU findutils) 4.8.0
$ printf "abc\ndef\ng" | xargs python3 -c 'from sys import argv; print(argv)'
['-c', 'abc', 'def', 'g']
$ printf "abc\ndef\ng" | xargs -i python3 -c 'from sys import argv; print(argv, repr("""{}"""))'
['-c'] 'abc'
['-c'] 'def'
['-c'] 'g' The following is to be appended to // Multiple lines
Command::cargo_bin("xargs")
.expect("found binary")
.args(["-i=_", "echo", "[_]"])
.write_stdin("abc\ndef\ng")
.assert()
.success()
.stderr(predicate::str::is_empty())
.stdout(predicate::str::diff("[abc]\n[def]\n[g]\n"));
Command::cargo_bin("xargs")
.expect("found binary")
.args(["-i", "echo", "{} {} foo"])
.write_stdin("bar\nbaz")
.assert()
.stdout(predicate::str::diff("bar bar foo\nbaz baz foo")); |
WorkaroundPass $ printf 'abc\ndef\ng' | xargs -I _ -n 1 echo [_]
[abc]
[def]
[g] Conflicting xargs options (GNU Findutils 4.9.0):
|
Hi! I've fixed the issue in normal cases, but if conflict options are given, things get complicated. (I need to change 141 lines) Currently, we throw a warning and take the last option. Lines 930 to 933 in baa09ba
Should I follow this behaviour? Or may I use |
Given the following stdin,
xargs -i echo [{}]
should giveinstead of
[abc def g]
.(Ubuntu)
(MSYS2 on Windows)
Platform: unknown-linux-gnu, pc-windows-msvc, other not tested.
Relavant codes
findutils/src/xargs/mod.rs
Lines 407 to 435 in baa09ba
There's no test on this behaviour.
findutils/tests/xargs_tests.rs
Lines 429 to 430 in baa09ba
Relates-to: #323
The text was updated successfully, but these errors were encountered: