12931048cSmillert#!/bin/sh - 2bfc7e83bSmillert# 3*bf198cc6Smillert# $OpenBSD: zmore,v 1.9 2019/01/25 00:19:26 millert Exp $ 472223939Sotto# 5*bf198cc6Smillert# Copyright (c) 2003 Todd C. Miller <millert@openbsd.org> 6bfc7e83bSmillert# 7bfc7e83bSmillert# Permission to use, copy, modify, and distribute this software for any 8bfc7e83bSmillert# purpose with or without fee is hereby granted, provided that the above 9bfc7e83bSmillert# copyright notice and this permission notice appear in all copies. 10bfc7e83bSmillert# 11bfc7e83bSmillert# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12bfc7e83bSmillert# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13bfc7e83bSmillert# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14bfc7e83bSmillert# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15bfc7e83bSmillert# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16bfc7e83bSmillert# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17bfc7e83bSmillert# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18bfc7e83bSmillert# 19bfc7e83bSmillert# Sponsored in part by the Defense Advanced Research Projects 20bfc7e83bSmillert# Agency (DARPA) and Air Force Research Laboratory, Air Force 21bfc7e83bSmillert# Materiel Command, USAF, under agreement number F39502-99-1-0512. 22bfc7e83bSmillert# 23bfc7e83bSmillert 24bfc7e83bSmillert# Pull out any command line flags so we can pass them to more/less 25bfc7e83bSmillertflags= 26bfc7e83bSmillertwhile test $# -ne 0; do 27bfc7e83bSmillert case "$1" in 28bfc7e83bSmillert --) 29bfc7e83bSmillert shift 30bfc7e83bSmillert break 31bfc7e83bSmillert ;; 328a66e41bSmillert -*|+*) 33bfc7e83bSmillert flags="$flags $1" 34bfc7e83bSmillert shift 35bfc7e83bSmillert ;; 36bfc7e83bSmillert *) 37bfc7e83bSmillert break 38bfc7e83bSmillert ;; 39bfc7e83bSmillert esac 40bfc7e83bSmillertdone 41bfc7e83bSmillert 427f66b237Sjsgif [ `basename $0` == "zless" ] ; then 43f049e498Szhuk pager=less 447f66b237Sjsgelse 45f049e498Szhuk pager=more 467f66b237Sjsgfi 477f66b237Sjsg 48411a9ed2Smillert# No files means read from stdin 49bfc7e83bSmillertif [ $# -eq 0 ]; then 507ac7b043Smpf compress -cdf 2>&1 | $pager $flags 51411a9ed2Smillert exit 0 52bfc7e83bSmillertfi 53bfc7e83bSmillert 54bfc7e83bSmillertoterm=`stty -g 2>/dev/null` 55bfc7e83bSmillertwhile test $# -ne 0; do 567ac7b043Smpf compress -cdf "$1" 2>&1 | $pager $flags 57bfc7e83bSmillert prev="$1" 58bfc7e83bSmillert shift 59411a9ed2Smillert if tty -s && test -n "$oterm" -a $# -gt 0; then 60bfc7e83bSmillert #echo -n "--More--(Next file: $1)" 61bfc7e83bSmillert echo -n "$prev (END) - Next: $1 " 62bfc7e83bSmillert trap "stty $oterm 2>/dev/null" 0 1 2 3 13 15 63bfc7e83bSmillert stty cbreak -echo 2>/dev/null 64bfc7e83bSmillert REPLY=`dd bs=1 count=1 2>/dev/null` 65bfc7e83bSmillert stty $oterm 2>/dev/null 66bfc7e83bSmillert trap - 0 1 2 3 13 15 67bfc7e83bSmillert echo 68bfc7e83bSmillert case "$REPLY" in 69bfc7e83bSmillert s) 70bfc7e83bSmillert shift 71bfc7e83bSmillert ;; 72bfc7e83bSmillert e|q) 73bfc7e83bSmillert break 74bfc7e83bSmillert ;; 75bfc7e83bSmillert esac 76411a9ed2Smillert fi 77bfc7e83bSmillertdone 78bfc7e83bSmillertexit 0 79