* NEWS, configure.ac (AC_INIT):
[debian/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 of the License, or
10 # (at your option) 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 along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21 PATH="BINDIR:$PATH"; export PATH
22
23 version="zmore (gzip) @VERSION@
24 Copyright (C) 2006 Free Software Foundation, Inc.
25 This is free software.  You may redistribute copies of it under the terms of
26 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
27 There is NO WARRANTY, to the extent permitted by law.
28
29 Written by Jean-loup Gailly."
30
31 usage="Usage: zmore [OPTION]... [FILE]...
32 Like 'more', but operate on the uncompressed contents of any compressed FILEs.
33
34 Report bugs to <bug-gzip@gnu.org>."
35
36 if test "`echo -n a`" = "-n a"; then
37   # looks like a SysV system:
38   n1=''; n2='\c'
39 else
40   n1='-n'; n2=''
41 fi
42 oldtty=`stty -g 2>/dev/null`
43 if stty -cbreak 2>/dev/null; then
44   cb='cbreak'; ncb='-cbreak'
45 else
46   # 'stty min 1' resets eof to ^a on both SunOS and SysV!
47   cb='min 1 -icanon'; ncb='icanon eof ^d'
48 fi
49 if test $? -eq 0 && test -n "$oldtty"; then
50    trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15
51 else
52    trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15
53 fi
54
55 if test $# = 0; then
56     if test -t 0; then
57         echo "$usage"
58     else
59         gzip -cdfq | eval ${PAGER-more}
60     fi
61 else
62     FIRST=1
63     for FILE
64     do
65         case $FILE in
66         --h*) exec echo "$usage";;
67         --v*) exec echo "$version";;
68         esac
69
70         < "$FILE" || continue
71         if test $FIRST -eq 0; then
72                 echo $n1 "--More--(Next file: $FILE)$n2"
73                 stty $cb -echo 2>/dev/null
74                 ANS=`dd bs=1 count=1 2>/dev/null`
75                 stty $ncb echo 2>/dev/null
76                 echo " "
77                 case "$ANS" in
78                 [eq]) exit;;
79                 esac
80         fi
81         if test "$ANS" != 's'; then
82                 echo "------> $FILE <------"
83                 gzip -cdfq -- "$FILE" | eval ${PAGER-more}
84         fi
85         if test -t 1; then
86                 FIRST=0
87         fi
88     done
89 fi