zmore revision 1.1
1#!/bin/sh - 2# 3# $OpenBSD: zmore,v 1.4 2003/07/29 07:42:45 otto Exp $ 4# 5# Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com> 6# 7# Permission to use, copy, modify, and distribute this software for any 8# purpose with or without fee is hereby granted, provided that the above 9# copyright notice and this permission notice appear in all copies. 10# 11# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18# 19# Sponsored in part by the Defense Advanced Research Projects 20# Agency (DARPA) and Air Force Research Laboratory, Air Force 21# Materiel Command, USAF, under agreement number F39502-99-1-0512. 22# 23 24# Pull out any command line flags so we can pass them to more/less 25flags= 26while test $# -ne 0; do 27 case "$1" in 28 --) 29 shift 30 break 31 ;; 32 -*) 33 flags="$flags $1" 34 shift 35 ;; 36 *) 37 break 38 ;; 39 esac 40done 41 42# No files means read from stdin 43if [ $# -eq 0 ]; then 44 compress -cdfq 2>&1 | ${PAGER-more} $flags 45 exit 0 46fi 47 48oterm=`stty -g 2>/dev/null` 49while test $# -ne 0; do 50 compress -cdfq "$1" 2>&1 | ${PAGER-more} $flags 51 prev="$1" 52 shift 53 if tty -s && test -n "$oterm" -a $# -gt 0; then 54 #echo -n "--More--(Next file: $1)" 55 echo -n "$prev (END) - Next: $1 " 56 trap "stty $oterm 2>/dev/null" 0 1 2 3 13 15 57 stty cbreak -echo 2>/dev/null 58 REPLY=`dd bs=1 count=1 2>/dev/null` 59 stty $oterm 2>/dev/null 60 trap - 0 1 2 3 13 15 61 echo 62 case "$REPLY" in 63 s) 64 shift 65 ;; 66 e|q) 67 break 68 ;; 69 esac 70 fi 71done 72exit 0 73