From 981acafde2511d757414aebe431439955eed890a Mon Sep 17 00:00:00 2001 From: Paul Janzen Date: Thu, 10 Jun 1999 22:58:25 +0000 Subject: jsm28@cam.ac.uk : handle PAGER in a manner consistent with the Single UNIX specification for mailx and man (http://www.opengroup.org/onlinepubs/7908799/xcu/mailx.html). --- games/quiz/quiz.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'games/quiz') diff --git a/games/quiz/quiz.c b/games/quiz/quiz.c index 816b23a6812..0529c78108a 100644 --- a/games/quiz/quiz.c +++ b/games/quiz/quiz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quiz.c,v 1.7 1999/03/27 04:45:25 pjanzen Exp $ */ +/* $OpenBSD: quiz.c,v 1.8 1999/06/10 22:58:24 pjanzen Exp $ */ /* $NetBSD: quiz.c,v 1.9 1995/04/22 10:16:58 cgd Exp $ */ /*- @@ -48,7 +48,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)quiz.c 8.3 (Berkeley) 5/4/95"; #else -static char rcsid[] = "$OpenBSD: quiz.c,v 1.7 1999/03/27 04:45:25 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: quiz.c,v 1.8 1999/06/10 22:58:24 pjanzen Exp $"; #endif #endif /* not lint */ @@ -168,9 +168,14 @@ show_index() QE *qp; const char *p, *s; FILE *pf; + const char *pager; - if ((pf = popen(_PATH_PAGER, "w")) == NULL) - err(1, "%s", _PATH_PAGER); + if (!isatty(1)) + pager = "/bin/cat"; + else if (!(pager = getenv("PAGER")) || (*pager == 0)) + pager = _PATH_PAGER; + if ((pf = popen(pager, "w")) == NULL) + err(1, "%s", pager); (void)fprintf(pf, "Subjects:\n\n"); for (qp = qlist.q_next; qp; qp = qp->q_next) { for (s = next_cat(qp->q_text); s; s = next_cat(s)) { -- cgit v1.2.3