From: espie Date: Mon, 1 Feb 2021 20:15:01 +0000 (+0000) Subject: in case we're not a tty, don't do anything else X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=730cf84e0d0ced961ab42ee1797e284be48d5640;p=openbsd in case we're not a tty, don't do anything else this does fix the grep case --- 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 # @@ -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