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

Don't buffer command output when running on a single thread? #522

Closed
guihkx opened this issue Dec 31, 2019 · 7 comments
Closed

Don't buffer command output when running on a single thread? #522

guihkx opened this issue Dec 31, 2019 · 7 comments

Comments

@guihkx
Copy link

guihkx commented Dec 31, 2019

Hey there.

I'm not sure if this is possible with fd already (sorry if it is), but wouldn't it make sense to not buffer command output, by default, when using -j 1 / --threads 1? For example:

$ fd --type directory --max-depth 1 --threads 1 --exec bash -c "date && sleep 3"

Currently, fd will buffer the output of bash and only display it after the process exits. But in this particular case, since bash will always run consecutively and not in parallel, I think it would make sense to not buffer them.

What do you think?
Thanks.

@guihkx guihkx changed the title Don't buffer command output when running on one thread? Don't buffer command output when running on a single thread? Dec 31, 2019
@sharkdp
Copy link
Owner

sharkdp commented Jan 1, 2020

Thank you very much for your feedback.

That sounds like a reasonable request to me. Not sure how difficult this would be to implement.

@maxtriano
Copy link
Contributor

Is this issue still open? If so I could take a stab at it

@guihkx
Copy link
Author

guihkx commented Jun 16, 2020

I guess so :)

@maxtriano
Copy link
Contributor

Wonderful, could you be a bit more specific on the behavior you're suggesting so I can get a better handle on where to start?

@guihkx
Copy link
Author

guihkx commented Jun 16, 2020

Okay, I think I can give you an example.

Imagine you have a folder with a bunch of audio files (mp3, aac, opus, flac). Now let's say you want to list only the mp3 files, but you want to listen to these audios as well, to make sure you're not deleting an important mp3 file, or whatever.

You'd do something like this:

$ fd -t f -e mp3 -j 1 -x mpv --no-audio-display {}

The -j 1 flag is important there to ensure mpv won't get spawned multiple times so you can listen to the audios one by one.

But here's the problem: Since fd is buffering the output of mpv, you can't send keystrokes to mpv using the terminal.

Using find, however, this is possible:

$ find . -type f -name '*.mp3' -exec mpv --no-audio-display {} \;

Since the output isn't going to be buffered in this case, you could, for example, press p to pause the current audio, or q to quit mpv and move to the next audio, and so on.

@sharkdp
Copy link
Owner

sharkdp commented Jun 17, 2020

Also, any long-running command that shows intermediate output that you would like to see. For example: search for some files and copy all of them somewhere with rsync with its --progress option.

@guihkx
Copy link
Author

guihkx commented Aug 11, 2021

Closing, as this has been implemented by #620

Thanks a lot for everyone's work! :)

@guihkx guihkx closed this as completed Aug 11, 2021
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

3 participants