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

Let --exec print final commands? #943

Closed
hg-zt opened this issue Jan 13, 2022 · 5 comments
Closed

Let --exec print final commands? #943

hg-zt opened this issue Jan 13, 2022 · 5 comments

Comments

@hg-zt
Copy link

hg-zt commented Jan 13, 2022

It is helpful for debugging and showing progress

The idea is

$ fd .mp4 --threads=1 --exec-show-command some-video-processing-program --input {} --output {.}-output.mp4 
> some-video-processing-program --input 1.mp4 --output 1-output.mp4
(...actual output of the program)
> some-video-processing-program --input 2.mp4 --output 2-output.mp4
> some-video-processing-program --input subdir/1.mp4 --output subdir/1-output.mp4

It's like set -x for bash.

@sharkdp
Copy link
Owner

sharkdp commented Jan 29, 2022

Thank you for the feature request. Did you see the discussion in #946? I think it would be good to think about this some more before implementing it. One idea to support this would be to implement #406 (see discussion therein)

@tmccombs
Copy link
Collaborator

Some other options (mentioned in the PR):

  • Add something to documentation mentioning you can put echo in front of the command to get a dry run with warning that it may not be the exact commands that are actually run.
  • add an equivalent of the -ok option in find that asks the user to confirm before actually running each command. Name could be interactive, confirm, verify, etc

@sharkdp
Copy link
Owner

sharkdp commented Jan 29, 2022

@tmccombs Note that this feature request is slightly different, as it asks for the printing of the command just before it is being executed (not a dry run). So the echo approach currently doesn't work. But it would work if we allowed for multiple -x/--exec instances.

@hg-zt
Copy link
Author

hg-zt commented Feb 8, 2022

Thank you for the feature request. Did you see the discussion in #946? I think it would be good to think about this some more before implementing it. One idea to support this would be to implement #406 (see discussion therein)

It is somehow different from --dry-run because one of my use cases is to show the progress for long-running jobs, i.e. which file/directory is under processing. Currently I'm using -x bash -c as a workaround.
And yeah I think the request could be solved by implementing #406.

@Flimm
Copy link

Flimm commented Aug 15, 2024

This issue was closed as completed, but I'm confused. What is the fix? How can I make fd print the command before running it?

The only solution I found was to resort to using xargs:

fd -0 --glob '*.mp4' | xargs -0 -I {} sh -c 'echo {} ; some-video-processing-program {}'

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

4 participants