Fd: Don't buffer command output when running on a single thread?

Created on 31 Dec 2019  路  6Comments  路  Source: sharkdp/fd

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.

feature-request

Most helpful comment

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.

All 6 comments

Thank you very much for your feedback.

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

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

I guess so :)

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?

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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nishithkhanna picture nishithkhanna  路  4Comments

blueray453 picture blueray453  路  4Comments

hungptit picture hungptit  路  3Comments

mathomp4 picture mathomp4  路  4Comments

christianbundy picture christianbundy  路  3Comments