If the tty is owned by a privileged user, and that privileged user is building sed after changing UID, the state of the tty's may look as follows: > tty /dev/pts/9 > ls -la $(tty) crw--w---- 1 root tty 136, 9 Feb 12 01:27 /dev/pts/9 > whoami builder > if [[ -r $(tty) ]]; then echo "readable"; else echo "not readable"; fi not readable This leads to the test producing the following diff: FAIL: testsuite/panic-tests =========================== --- exp-err-tty 2017-01-06 15:42:36.073141748 +1300 +++ err-tty 2017-01-06 15:42:36.086141949 +1300 @@ -1 +1 @@ -sed: couldn't edit X: is a terminal +sed: can't read /dev/pts/3: Permission denied FAIL testsuite/panic-tests.sh (exit status: 1) And failing. This failure makes sense however, and there's no sane way I know of to make the terminal readable, other than demanding sed run the test inside a pty it created. So an effective workaround is just guard the test with a -r check like it presently has for -w , because the tty dev can't be read for sed to decide "its a tty" in this condition. Tested patch that adds this trivial check attached. Thanks. --- Downstream Bug: https://bugs.gentoo.org/show_bug.cgi?id=604798