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

FeatureComplete: implement exec[dir] + #6

Open
mcharsley opened this issue Mar 15, 2017 · 0 comments
Open

FeatureComplete: implement exec[dir] + #6

mcharsley opened this issue Mar 15, 2017 · 0 comments

Comments

@mcharsley
Copy link
Contributor

We (will soon) have support for -exec and -execdir clauses that end with a ';' (i.e. run this command for every file/directory). We need to also add support for clauses that end with a '+' (i.e. batch up the files/dirs and then run the command for as many as possible at once).

Unfortunately this isn't easy in an os-independent way because the standard library doesn't expose any way of telling when a command-line is going to be too long. I raised rust-lang/rust#40384 but it's not getting much traction.

So we need to go for a lowest common denominator approach. Choose a hard-coded limit (I'd suggest a bit less than 8kB, to allow for any inaccuracies in the next bit), come up with an efficient way of estimating the command-line length (doing this accurately is going to involve reimplementing too much of std::process::Command) and trigger the command when the estimated total goes over the limit.

To do this we need to

  • add a MultiExecMatcher class to find::matchers::exec (implementing the finished_dir and finished methods to make the exec calls for any remaining files that haven't been executed yet)
  • tweak find::process_dir to call the finished and finished_dir methods as appropriate
  • tweak find::matchers::build_matcher_tree to stop returning an error when -exec[dir] finds a + and create a MultiExecMatcher instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant