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

support for longer argument lists with -X? #766

Closed
githorse opened this issue May 14, 2021 · 2 comments
Closed

support for longer argument lists with -X? #766

githorse opened this issue May 14, 2021 · 2 comments

Comments

@githorse
Copy link

When I try to use -X on a giant argument list, it fails:

$ fd /giant/directory --type f -X stat 
[fd error]: Problem while executing command: Argument list too long (os error 7)

Ok, makes sense, since my argument list is 100k files long. But find -exec actually works here:

$ find . -type f -exec stat {} +
# seems to work

AFAIK the + means that all results are passed to stat, so it seems that stat actually supports argument lists that long. Or maybe find is batching them up somehow? Using find -exec + is way faster than find -exec \;, which passes them one-by-one, so it's doing something different for sure.

Would it be possible for fd to support (ridiculously) long argument lists as well?

@sharkdp
Copy link
Owner

sharkdp commented May 16, 2021

Thank you for reporting this. Please see #410.

@sharkdp sharkdp closed this as completed May 16, 2021
@sharkdp
Copy link
Owner

sharkdp commented May 16, 2021

AFAIK the + means that all results are passed to stat, so it seems that stat actually supports argument lists that long. Or maybe find is batching them up somehow?

find is calling the external multiple times, if that is needed (if the argument list is too long). So yet, it's executing in batches. fd should do the same for -X.

Using find -exec + is way faster than find -exec \;, which passes them one-by-one, so it's doing something different for sure.

Exactly. -exec … + is like fds -X/--exec-batch. A normal -exec without the + is like fds -x/--exec. From my experience, -X is almost always what you want.

Counterexamples where you want -x/--exec:

  • Commands that only support a single filename argument
  • Cases where you want to profit from fds parallel command execution (e.g. long-running commands)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants