Return a non-zero exit code when an operation cannot be performed
Example
$ xtermcontrol --get-bg
xtermcontrol: --get-bg is unsupported or disallowed by this terminal. See also, TROUBLESHOOTING section of xtermcontrol(1) manpage.
$ echo $?
0
If xtermcontrol returned something else than zero, it would be much easier to handle such situations in scripts.
That is tricky because xtermcontrol accepts multiple arguments that may succeed or fail independently, e.g.
$ xtermcontrol --get-fg --get-title
rgb:0000/0000/0000
xtermcontrol: --get-title is unsupported or disallowed by this terminal. See also, TROUBLESHOOTING section of xtermcontrol(1) manpage.
As a workaround for your example, perhaps test stdout or make a small wrapper script?
#!/bin/bash
bg=$(xtermcontrol --get-bg 2>/dev/null)
if [[ -z $bg ]]; then
exit 1
else
echo $bg
fi
Perhaps a non-zero exit code is warranted if none of the requests succeed? This would cover my case as well.
How about exiting with the number of failed requests? That'd cover the successful case and allow to differentiate between complete and partial failures.
I need this too, I think having to create a wrapper script to get a status is too much.
I like the idea of returning the number of failed operations best, but fail-if-all-fail is also okay with me.
There is also the possibility of having an option to turn on (or off) reporting a nonzero status if an operation fails.