From 4e22c3b1b31fc4dd225bc22d0e16133481add6fe Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 23 Jun 2003 19:04:25 +0000 Subject: Make zmore read from stdin when no files are specified and try to ascertain wether or not we have a tty. Also add a skeleton manual page. --- usr.bin/compress/zmore | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'usr.bin/compress/zmore') diff --git a/usr.bin/compress/zmore b/usr.bin/compress/zmore index 7066a663929..0f21517de69 100644 --- a/usr.bin/compress/zmore +++ b/usr.bin/compress/zmore @@ -37,32 +37,35 @@ while test $# -ne 0; do esac done +# No files means read from stdin +# XXX - cannot distinguish between gzip or compress, assume gzip if [ $# -eq 0 ]; then - echo "usage: zmore filename ..." - exit 1 + compress -cdfgq 2>&1 | ${PAGER-more} $flags + exit 0 fi oterm=`stty -g 2>/dev/null` while test $# -ne 0; do - gzip -cdfq "$1" 2>&1 | ${PAGER-more} $flags + compress -cdfq "$1" 2>&1 | ${PAGER-more} $flags prev="$1" shift - test $# -eq 0 && break - #echo -n "--More--(Next file: $1)" - echo -n "$prev (END) - Next: $1 " - trap "stty $oterm 2>/dev/null" 0 1 2 3 13 15 - stty cbreak -echo 2>/dev/null - REPLY=`dd bs=1 count=1 2>/dev/null` - stty $oterm 2>/dev/null - trap - 0 1 2 3 13 15 - echo - case "$REPLY" in - s) - shift - ;; - e|q) - break - ;; - esac + if tty -s && test -n "$oterm" -a $# -gt 0; then + #echo -n "--More--(Next file: $1)" + echo -n "$prev (END) - Next: $1 " + trap "stty $oterm 2>/dev/null" 0 1 2 3 13 15 + stty cbreak -echo 2>/dev/null + REPLY=`dd bs=1 count=1 2>/dev/null` + stty $oterm 2>/dev/null + trap - 0 1 2 3 13 15 + echo + case "$REPLY" in + s) + shift + ;; + e|q) + break + ;; + esac + fi done exit 0 -- cgit v1.2.3