sharkdp / fd

A simple, fast and user-friendly alternative to 'find'
Apache License 2.0
34.2k stars 814 forks source link

Option to give non-zero exit code in precense of file system errors #1638

Open VRehnberg opened 1 week ago

VRehnberg commented 1 week ago

I'd like to use fd for checking for presence of stale file handles. Currently I can do:

fd . /path/to/nfs/mount/ --show-errors -X true 2> /dev/stdout | grep -qv "Stale file handle"

to get a command with a non-zero exit code in presence of such file system errors. However, having to output all the paths makes this much slower than running quietly.

Ideally one or more of the following alternatives should work.

1 Output errors even when rest is silenced --show-errors -q

fd . /path/to/nfs/mount/ --show-errors -q | grep -qv "Stale file handle"

2 When there are file system errors output a non-zero exit code

fd . /path/to/nfs/mount/ -q

3 Option to give non-zero exit code in presence of file system errors

fd . /path/to/nfs/mount/ --raise-error -q

would either exit with non-zero exit code on first file system error or after everything if there was any file system error.

VRehnberg commented 1 week ago

Ah, probably misunderstood what -q does. Probably exits on first match and that's why it is so much faster.

Would still be nice with some possibility to just check for file system errors without dealing with lots of output.