2 # SPDX-License-Identifier: GPL-2.0-or-later
4 # Copyright (C) 2001, 2002, 2007 Free Software Foundation
5 # Copyright (C) 1992, 1993 Jean-loup Gailly
7 # Modified for XZ Utils by Andrew Dudman and Lasse Collin.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 @enable_path_for_scripts@
20 #SET_PATH - This line is a placeholder to ease patching this script.
22 # Instead of unsetting XZ_OPT, just make sure that xz will use file format
23 # autodetection. This way memory usage limit and thread limit can be
24 # specified via XZ_OPT.
25 xz='@xz@ --format=auto'
27 version='xzmore (@PACKAGE_NAME@) @PACKAGE_VERSION@'
29 usage="Usage: ${0##*/} [OPTION]... [FILE]...
30 Like 'more', but operate on the uncompressed contents of xz compressed FILEs.
32 Report bugs to <@PACKAGE_BUGREPORT@>."
35 --help) printf '%s\n' "$usage" || exit 2; exit;;
36 --version) printf '%s\n' "$version" || exit 2; exit;;
39 oldtty=`stty -g 2>/dev/null`
40 if stty -cbreak 2>/dev/null; then
41 cb='cbreak'; ncb='-cbreak'
43 # 'stty min 1' resets eof to ^a on both SunOS and SysV!
44 cb='min 1 -icanon'; ncb='icanon eof ^d'
46 if test $? -eq 0 && test -n "$oldtty"; then
47 trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15
49 trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15
54 printf '%s\n' "$usage"; exit 1
56 $xz -cdfqQ | eval "${PAGER:-more}"
62 if test $FIRST -eq 0; then
63 printf "%s--More--(Next file: %s)" "" "$FILE"
64 stty $cb -echo 2>/dev/null
65 ANS=`dd bs=1 count=1 2>/dev/null`
66 stty $ncb echo 2>/dev/null
72 if test "$ANS" != 's'; then
73 printf '%s\n' "------> $FILE <------"
74 $xz -cdfqQ -- "$FILE" | eval "${PAGER:-more}"