diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2021-02-01 20:15:02 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2021-02-01 20:15:02 +0000 |
commit | 545574f8f3d496cace1b878cf60742d6a17e094c (patch) | |
tree | 4d89203747717de82082515c88f31a5bf4936447 /usr.sbin | |
parent | 1482769e37697c3467b37f417886d7936e3b27d1 (diff) |
in case we're not a tty, don't do anything else
this does fix the grep case
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/State.pm | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/State.pm b/usr.sbin/pkg_add/OpenBSD/State.pm index 1a26a9a471b..ff600033cbf 100644 --- a/usr.sbin/pkg_add/OpenBSD/State.pm +++ b/usr.sbin/pkg_add/OpenBSD/State.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: State.pm,v 1.68 2021/01/31 15:22:55 espie Exp $ +# $OpenBSD: State.pm,v 1.69 2021/02/01 20:15:01 espie Exp $ # # Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org> # @@ -143,10 +143,13 @@ OpenBSD::Auto::cache(can_output, sub { require POSIX; + return 1 if !-t STDOUT; # XXX uses POSIX semantics so fd, we can hardcode stdout ;) my $s = POSIX::tcgetpgrp(1); - # note that STDOUT may be redirected (tcgetpgrp() will fail) - return $s == -1 || getpgrp() == $s; + # note that STDOUT may be redirected + # (tcgetpgrp() returns 0 for pipes and -1 for files) + # (we shouldn't be there because of the tty test) + return $s <= 0 || getpgrp() == $s; }); sub sync_display |