]> git.cworth.org Git - gzip/blob - zmore.in
Imported Debian patch 1.3.5-10sarge1
[gzip] / zmore.in
1 :
2 #!/bin/sh
3
4 # Copyright (C) 2001, 2002 Free Software Foundation
5 # Copyright (C) 1992, 1993 Jean-loup Gailly
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 # 02111-1307, USA.
21
22 PATH="BINDIR:$PATH"; export PATH
23 if test "`echo -n a`" = "-n a"; then
24   # looks like a SysV system:
25   n1=''; n2='\c'
26 else
27   n1='-n'; n2=''
28 fi
29 oldtty=`stty -g 2>/dev/null`
30 if stty -cbreak 2>/dev/null; then
31   cb='cbreak'; ncb='-cbreak'
32 else
33   # 'stty min 1' resets eof to ^a on both SunOS and SysV!
34   cb='min 1 -icanon'; ncb='icanon eof ^d'
35 fi
36 if test $? -eq 0 && test -n "$oldtty"; then
37    trap 'stty $oldtty 2>/dev/null; exit' INT QUIT TRAP USR1 PIPE TERM
38 else
39    trap 'stty $ncb echo 2>/dev/null; exit' INT QUIT TRAP USR1 PIPE TERM
40 fi
41
42 if test $# = 0; then
43     if test -t 0; then
44         echo usage: ${ZMORE_PROGRAM_NAME-zmore} files...
45     else
46         gzip -cdfq | eval more
47     fi
48 else
49     FIRST=1
50     for FILE
51     do
52         < "$FILE" || continue
53         if test $FIRST -eq 0; then
54                 echo $n1 "--More--(Next file: $FILE)$n2"
55                 stty $cb -echo 2>/dev/null
56                 ANS=`dd bs=1 count=1 2>/dev/null` 
57                 stty $ncb echo 2>/dev/null
58                 echo " "
59                 case "$ANS" in
60                 [eq]) exit;;
61                 esac
62         fi
63         if test "$ANS" != 's'; then
64                 echo "------> $FILE <------"
65                 gzip -cdfq "$FILE" | more
66         fi
67         if test -t 1; then
68                 FIRST=0
69         fi
70     done
71 fi