by theteapot · 4y ago · 0 comments
> chronic: runs a command quietly unless it fails
Isn't that just `command >/dev/null`?
> ifdata: get network interface info without parsing ifconfig output
`ip link show <if>`?
> isutf8: check if a file or standard input is utf-8
`file` for files. For stdin, when is it not utf8 - unless you've got some weird system configuration?
> lckdo: execute a program with a lock held
`flock`?
Often times you want to run a command silently (like in a build script), but if it fails with a nonzero exit status, you want to then display not only the stderr but the stdout as well. I’ve written makefile hacks in the past that do this to silence overly-chatty compilers where we don’t really care what it’s outputting unless it fails, in which case we want all the output. It would’ve been nice to have this tool at the time to avoid reinventing it.
> Isn't that just `command >/dev/null`?
no. that just shows your stderr, not stdout if it failed. and you get stderr even if it doesn't fail.
new ideas are great. but this isn't a new idea. "run a command silently unless it fails" is basic; it's the sort of thing that should make one think "i should search the shell man pages" rather than "i should roll my own new utility."