Open ghen2 opened 4 years ago
or, you can ignore output from stderr
echo "get a" | ./tools/ssdb-cli 2>/dev/null
That's the point, I don't want to simply discard stderr, or I will not see real errors either (like connection refused etc).
I'd also like this feature. One way to do it is a "headless" mode, where you can pass a command without needing stdin nor shell. When a command is present, just print any output from that command and exit without ever opening the cli's shell and accompanying noise.
Currently I do stuff like this from cron, but would be nice to monitor for connection errors easier:
newline=$'\n' && ssdb-cli <<< "compact${newline}q"
Currently ssdb-cli prints banner and prompt on stderr, regulur output on stdout, and errors on stderr. This makes it hard to use in (cron) scripts because you can't just discard stderr to filter unneeded output, or you will miss errors as well.
Below patch is a draft attempt at minimizing output when stdin is not a tty (the code already disables histfile in this case), but it can probably be improved.
An alternative to the "isatty" test would be a
--silent
command line option to print only errors.