Skip to content
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

[BUG] fd -X don't process all files found #1259

Closed
1 task done
kkew3 opened this issue Feb 17, 2023 · 6 comments
Closed
1 task done

[BUG] fd -X don't process all files found #1259

kkew3 opened this issue Feb 17, 2023 · 6 comments
Labels

Comments

@kkew3
Copy link

kkew3 commented Feb 17, 2023

Checks

  • I have read the troubleshooting section and still think this is a bug.

Describe the bug you encountered:

fd -X doesn't process all found files when the result list is very long; long filenames makes the issue worse. For example, when there are tens of thousands of txt files in a directory and I run fd -etxt -X du -sh, the total size added up will be smaller than the ground truth.

I'm not sure, but this may be related to #410 and #441.

Describe what you expected to happen:

As this section, I expect -X function equivalently with xargs and/or parallel, that is, to process all files even if processing them all at once exceeds the command line length limit.

What version of fd are you using?

fd 8.6.0

Which operating system / distribution are you on?

Darwin 21.6.0 x86_64

zsh: command not found: lsb_release
@kkew3 kkew3 added the bug label Feb 17, 2023
@tavianator
Copy link
Collaborator

Are you sure that fd without -X is finding all the relevant files? Did you try with -u to make sure hidden and gitignored files are also included?

@tmccombs
Copy link
Collaborator

Is your list of files long enough it is exceeding the maximum command line size? If so there isn't much we can do about it. For du specifically it would probably work better to pipe the output of fd, with the -0 flag to du with the --files0-from flag (reading from stdin).

@kkew3
Copy link
Author

kkew3 commented Feb 18, 2023

Thank you so much for your advice. I'll close the issue if it's not possible to solve. Thanks again.

@kkew3 kkew3 closed this as completed Feb 18, 2023
@sharkdp
Copy link
Owner

sharkdp commented Feb 18, 2023

No, wait. We spent a lot of time on this actually (as described in #410). This should work since fd 8.4 (see https://github.com/sharkdp/fd/releases/tag/v8.4.0 => bugfixes). If the argument list is too long, we will launch the process again with another batch of arguments.

@kkew3 Did you try the suggestion by @tavianator?

@sharkdp sharkdp reopened this Feb 18, 2023
@tmccombs
Copy link
Collaborator

Yes, if it is exceeding the max length it should result in multiple invocations. In the case of du, that would result in multiple summaries. So if you are using du and want a single summary, you'll probably want to pipe to du instead. And in that case, xarga would have a similar problem. Did you get multiple summary lines @kkew3?

@kkew3
Copy link
Author

kkew3 commented Feb 19, 2023

Sorry, it's my fault. Surly it produces multiple summary lines. I did tail -n1 to get the expected summary line before. Thank you so much for your kind explanation.

@kkew3 kkew3 closed this as completed Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants