EOF
check $expected $actual
-# Produce no standard output if no messages match and standard output
-# is a tty. To test that, move stderr to stdout.
-echo `pick -subject message.3 -and -from Test4 >&2-` >$actual
-cat >$expected <<EOF
-EOF
-check $expected $actual
+set +e
+
+if test -w /dev/tty; then
+ # Produce no standard output if no messages match and standard
+ # output is a tty. To test that even when run with stdout
+ # detached, write directly to /dev/tty. Can't capture the
+ # output so hopefully the user will notice it.
+ pick -subject message.3 -and -from Test4 >/dev/tty 2>/dev/null
+else
+ echo "$0: skip tty test because can't write to /dev/tty"
+fi
# Also, check that the exit status is 1.
-set +e
-pick -subject message.3 -and -from Test4 2>/dev/null
+pick -subject message.3 -and -from Test4 >/dev/null 2>&1
run_test "echo $?" '1'
+
set -e
# Test -cc.
cat >$expected <<EOF
11
EOF
-
check $expected $actual
+
# Invert exit status so execution doesn't terminate due to -e.
! pick -after '29 Sep 2008 00:00:00' >$actual 2>/dev/null
cat >$expected <<EOF