Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / gnu / usr.bin / gzip / zmore
1 #!/bin/sh
2 #
3 # $FreeBSD: src/gnu/usr.bin/gzip/zmore,v 1.5 1999/08/27 23:35:56 peter Exp $
4 # $DragonFly: src/gnu/usr.bin/gzip/Attic/zmore,v 1.2 2003/06/17 04:25:46 dillon Exp $
5
6 if test "`echo -n a`" = "-n a"; then
7   # looks like a SysV system:
8   n1=''; n2='\c'
9 else
10   n1='-n'; n2=''
11 fi
12 oldtty=`stty -g 2>/dev/null`
13 if stty -cbreak 2>/dev/null; then
14   cb='cbreak'; ncb='-cbreak'
15 else
16   # 'stty min 1' resets eof to ^a on both SunOS and SysV!
17   cb='min 1 -icanon'; ncb='icanon eof ^d'
18 fi
19 if test $? -eq 0 -a -n "$oldtty"; then
20    trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15
21 else
22    trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15
23 fi
24
25 if test $# = 0; then
26     if test -t 0; then
27         echo usage: zmore files...
28     else
29         gzip -cdfq | eval ${PAGER-more}
30     fi
31 else
32     FIRST=1
33     for FILE
34     do
35         if test $FIRST -eq 0; then
36                 echo $n1 "--More--(Next file: $FILE)$n2"
37                 stty $cb -echo 2>/dev/null
38                 ANS=`dd bs=1 count=1 2>/dev/null` 
39                 stty $ncb echo 2>/dev/null
40                 echo " "
41                 if test "$ANS" = 'e' -o "$ANS" = 'q'; then
42                         exit
43                 fi
44         fi
45         if test "$ANS" != 's'; then
46                 echo "------> $FILE <------"
47                 gzip -cdfq "$FILE" | eval ${PAGER-more}
48         fi
49         if test -t; then
50                 FIRST=0
51         fi
52     done
53 fi