1#!/bin/sh
2
3PATH="/bin:$PATH"; export PATH
4if test "`echo -n a`" = "-n a"; then
5  # looks like a SysV system:
6  n1=''; n2='\c'
7else
8  n1='-n'; n2=''
9fi
10oldtty=`stty -g 2>/dev/null`
11if stty -cbreak 2>/dev/null; then
12  cb='cbreak'; ncb='-cbreak'
13else
14  # 'stty min 1' resets eof to ^a on both SunOS and SysV!
15  cb='min 1 -icanon'; ncb='icanon eof ^d'
16fi
17if test $? -eq 0 -a -n "$oldtty"; then
18   trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15
19else
20   trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15
21fi
22
23if test $# = 0; then
24    if test -t 0; then
25	echo usage: zmore files...
26    else
27	gzip -cdfq | eval ${PAGER-less}
28    fi
29else
30    FIRST=1
31    for FILE
32    do
33	if test $FIRST -eq 0; then
34		echo $n1 "--More--(Next file: $FILE)$n2"
35		stty $cb -echo 2>/dev/null
36		ANS=`dd bs=1 count=1 2>/dev/null` 
37		stty $ncb echo 2>/dev/null
38		echo " "
39		if test "$ANS" = 'e' -o "$ANS" = 'q'; then
40			exit
41		fi
42	fi
43	if test "$ANS" != 's'; then
44		echo "------> $FILE <------"
45		gzip -cdfq "$FILE" | eval ${PAGER-less}
46	fi
47	if test -t; then
48		FIRST=0
49	fi
50    done
51fi
52