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