3 # Copyright (C) 1998, 2002, 2006-2007, 2010-2022 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 version
="zless (gzip) @VERSION@
20 Copyright (C) 2007, 2011-2018 Free Software Foundation, Inc.
21 This is free software. You may redistribute copies of it under the terms of
22 the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
23 There is NO WARRANTY, to the extent permitted by law.
25 Written by Paul Eggert."
27 usage
="Usage: $0 [OPTION]... [FILE]...
28 Like 'less', but operate on the uncompressed contents of any compressed FILEs.
30 Options are the same as for 'less'.
32 Report bugs to <bug-gzip@gnu.org>."
35 --help) printf '%s\n' "$usage" ||
exit 1; exit;;
36 --version) printf '%s\n' "$version" ||
exit 1; exit;;
39 if test "${LESSMETACHARS+set}" != set; then
40 # Work around a bug in less 394 and earlier;
41 # it mishandles the metacharacters '$%=~'.
46 LESSMETACHARS
="$space$tab$newline'"';*?"()<>[|&^`#\$%=~'
50 less_version
=`less -V 2>/dev/null`
53 less' '4[6-9][0-9]* | \
54 less' '[5-9][0-9][0-9]* | \
55 less' '[1-9][0-9][0-9][0-9]*)
56 check_exit_status
='|';;
57 *) check_exit_status
='';;
61 less' '4[3-9][0-9]* | \
62 less' '[5-9][0-9][0-9]* | \
63 less' '[1-9][0-9][0-9][0-9]*)
64 use_input_pipe_on_stdin
='-';;
65 *) use_input_pipe_on_stdin
='';;
68 LESSOPEN
="|$check_exit_status${use_input_pipe_on_stdin}'gzip' -cdfq -- %s"