Ideally, this would be scriptable in shell, but Perl or Python would be fine. C code could be helpful, but probably fails cost/benefit.
I recognize that redirection to a
There is a Linux-specific solution that does what I want:
exec 9>&1
case `readlink /dev/fd/9` in
pipe:\[*\]) echo stdout is a pipe ;;
*) echo stdout is not a pipe ;;
esac
but that isn't the answer I am looking for as I want this to run on xBSD as well.
I've made this answer community wiki, so feel free to improve it, but if you have a non-Linux solution (or a Linux-specific solution using another technique), please create a new answer.