gzip: fix NO_SIZE_CHECK for VMS
[gzip.git] / zmore.in
blob547c527b6055e84c98191f25d989a189163fbe20
1 #!/bin/sh
3 # Copyright (C) 2001, 2002, 2007 Free Software Foundation
4 # Copyright (C) 1992, 1993 Jean-loup Gailly
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 bindir=@bindir@
21 case $1 in
22 --__bindir) bindir=${2?}; shift; shift;;
23 esac
24 PATH=$bindir:$PATH; export PATH
26 version="zmore (gzip) @VERSION@
27 Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
28 This is free software. You may redistribute copies of it under the terms of
29 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
30 There is NO WARRANTY, to the extent permitted by law.
32 Written by Jean-loup Gailly."
34 usage="Usage: $0 [OPTION]... [FILE]...
35 Like 'more', but operate on the uncompressed contents of any compressed FILEs.
37 Report bugs to <bug-gzip@gnu.org>."
39 if test "`echo -n a`" = "-n a"; then
40 # looks like a SysV system:
41 n1=''; n2='\c'
42 else
43 n1='-n'; n2=''
45 oldtty=`stty -g 2>/dev/null`
46 if stty -cbreak 2>/dev/null; then
47 cb='cbreak'; ncb='-cbreak'
48 else
49 # 'stty min 1' resets eof to ^a on both SunOS and SysV!
50 cb='min 1 -icanon'; ncb='icanon eof ^d'
52 if test $? -eq 0 && test -n "$oldtty"; then
53 trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15
54 else
55 trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15
58 if test $# = 0; then
59 if test -t 0; then
60 echo >&2 "$0: invalid number of operands; try \`$0 --help' for help"
61 else
62 gzip -cdfq | eval ${PAGER-more}
64 else
65 FIRST=1
66 for FILE
68 case $FILE in
69 --h*) exec echo "$usage";;
70 --v*) exec echo "$version";;
71 esac
73 < "$FILE" || continue
74 if test $FIRST -eq 0; then
75 echo $n1 "--More--(Next file: $FILE)$n2"
76 stty $cb -echo 2>/dev/null
77 ANS=`dd bs=1 count=1 2>/dev/null`
78 stty $ncb echo 2>/dev/null
79 echo " "
80 case "$ANS" in
81 [eq]) exit;;
82 esac
84 if test "$ANS" != 's'; then
85 echo "------> $FILE <------"
86 gzip -cdfq -- "$FILE" | eval ${PAGER-more}
88 if test -t 1; then
89 FIRST=0
91 done