From: jsm Date: Thu, 16 Dec 1999 13:45:48 +0000 (+0000) Subject: Make quiz use POSIX.2 pager handling. X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/commitdiff_plain/fe13a520d4840d1a408eb09cb1d6c24880534e94?hp=f3b3c25a6879b367279b16979a7f9f634720ae7c Make quiz use POSIX.2 pager handling. --- diff --git a/quiz/quiz.c b/quiz/quiz.c index 18b0f49d..3d8a3ff1 100644 --- a/quiz/quiz.c +++ b/quiz/quiz.c @@ -1,4 +1,4 @@ -/* $NetBSD: quiz.c,v 1.16 1999/09/17 17:07:11 jsm Exp $ */ +/* $NetBSD: quiz.c,v 1.17 1999/12/16 13:45:48 jsm Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\ #if 0 static char sccsid[] = "@(#)quiz.c 8.3 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: quiz.c,v 1.16 1999/09/17 17:07:11 jsm Exp $"); +__RCSID("$NetBSD: quiz.c,v 1.17 1999/12/16 13:45:48 jsm Exp $"); #endif #endif /* not lint */ @@ -169,9 +169,16 @@ 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 = "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)) {