aaronriekenberg / rust-parallel

Fast command line app in rust/tokio to run commands in parallel. Similar interface to GNU parallel or xargs plus useful features. Listed in Awesome Rust utilities.
MIT License
160 stars 7 forks source link

Rust parallel tries to execute even if regex doesnt match #10

Closed Quackdoc closed 9 months ago

Quackdoc commented 10 months ago

I send the below list into rust-parallel and execute this command;

rust-parallel.exe -j 4 -r '(.*)\\(.*).(png)' echo `{0`} `|`| `{1`} `|`| `{2`}.jxl

and the output is given below that. It would be nice if the input lines could be sent to a log file or stderr instead

02.png
2022-12-13 01_48_21-Clipboard.png
2022-12-13 02_04_49-Clipboard.png
bottle1.png
glass1.png
house_1.png
ina.png
test.png
test\02.png
{0} || {1} || {2}.jxl
{0} || {1} || {2}.jxl
{0} || {1} || {2}.jxl
{0} || {1} || {2}.jxl
{0} || {1} || {2}.jxl
{0} || {1} || {2}.jxl
{0} || {1} || {2}.jxl
{0} || {1} || {2}.jxl
test\02.png || test || 02.jxl
aaronriekenberg commented 9 months ago

Agree this is a bug, will fix this. Thanks for reporting this!

aaronriekenberg commented 9 months ago

This is fixed in version 1.13.0

rust-parallel now emits WARN log for input lines that do not match provided regular expression. It will not attempt to run commands for these lines.

Example on macos unix shell where file test contains your file list above:

cat test | rust-parallel -j 4 -r '(.*)\\(.*).(png)' echo '{0} || {1} || {2}.jxl'
2024-01-07T16:00:06.983972Z  WARN process_buffered_input_line{line=stdin:1}: rust_parallel::parser::regex: regex did not match input data: 02.png
2024-01-07T16:00:06.983999Z  WARN process_buffered_input_line{line=stdin:2}: rust_parallel::parser::regex: regex did not match input data: 2022-12-13 01_48_21-Clipboard.png
2024-01-07T16:00:06.984007Z  WARN process_buffered_input_line{line=stdin:3}: rust_parallel::parser::regex: regex did not match input data: 2022-12-13 02_04_49-Clipboard.png
2024-01-07T16:00:06.984014Z  WARN process_buffered_input_line{line=stdin:4}: rust_parallel::parser::regex: regex did not match input data: bottle1.png
2024-01-07T16:00:06.984020Z  WARN process_buffered_input_line{line=stdin:5}: rust_parallel::parser::regex: regex did not match input data: glass1.png
2024-01-07T16:00:06.984026Z  WARN process_buffered_input_line{line=stdin:6}: rust_parallel::parser::regex: regex did not match input data: house_1.png
2024-01-07T16:00:06.984032Z  WARN process_buffered_input_line{line=stdin:7}: rust_parallel::parser::regex: regex did not match input data: ina.png
2024-01-07T16:00:06.984037Z  WARN process_buffered_input_line{line=stdin:8}: rust_parallel::parser::regex: regex did not match input data: test.png
test\02.png || test || 02.jxl