2009-07-05 19:25:17 +00:00
|
|
|
#!@POSIX_SHELL@
|
2024-02-12 15:09:10 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2009-07-05 19:25:17 +00:00
|
|
|
|
|
|
|
# Copyright (C) 1998, 2002, 2006, 2007 Free Software Foundation
|
|
|
|
|
2009-07-19 08:09:31 +00:00
|
|
|
# The original version for gzip was written by Paul Eggert.
|
2009-07-05 19:25:17 +00:00
|
|
|
# Modified for XZ Utils by Andrew Dudman and Lasse Collin.
|
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
2019-09-24 20:02:40 +00:00
|
|
|
@enable_path_for_scripts@
|
2009-07-05 19:25:17 +00:00
|
|
|
#SET_PATH - This line is a placeholder to ease patching this script.
|
|
|
|
|
|
|
|
# Instead of unsetting XZ_OPT, just make sure that xz will use file format
|
|
|
|
# autodetection. This way memory usage limit and thread limit can be
|
|
|
|
# specified via XZ_OPT.
|
|
|
|
xz='@xz@ --format=auto'
|
|
|
|
|
|
|
|
version='xzless (@PACKAGE_NAME@) @VERSION@'
|
|
|
|
|
|
|
|
usage="Usage: ${0##*/} [OPTION]... [FILE]...
|
|
|
|
Like 'less', but operate on the uncompressed contents of xz compressed FILEs.
|
|
|
|
|
|
|
|
Options are the same as for 'less'.
|
|
|
|
|
|
|
|
Report bugs to <@PACKAGE_BUGREPORT@>."
|
|
|
|
|
|
|
|
case $1 in
|
2022-07-18 16:18:48 +00:00
|
|
|
--help) printf '%s\n' "$usage" || exit 2; exit;;
|
|
|
|
--version) printf '%s\n' "$version" || exit 2; exit;;
|
2009-07-05 19:25:17 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
if test "${LESSMETACHARS+set}" != set; then
|
|
|
|
# Work around a bug in less 394 and earlier;
|
|
|
|
# it mishandles the metacharacters '$%=~'.
|
|
|
|
space=' '
|
|
|
|
tab=' '
|
|
|
|
nl='
|
|
|
|
'
|
|
|
|
LESSMETACHARS="$space$tab$nl'"';*?"()<>[|&^`#\$%=~'
|
|
|
|
fi
|
|
|
|
|
2024-02-09 21:00:05 +00:00
|
|
|
VER=$(less -V | { read _ ver _ && echo ${ver%%.*}; })
|
2024-02-09 21:21:01 +00:00
|
|
|
if test "$VER" -ge 451; then
|
|
|
|
# less 451 or later: If the compressed file is valid but has
|
|
|
|
# zero bytes of uncompressed data, using two vertical bars ||- makes
|
|
|
|
# "less" check the exit status of xz and if it is zero then display
|
|
|
|
# an empty file. With a single vertical bar |- and no output from xz,
|
|
|
|
# "less" would attempt to display the raw input file instead.
|
|
|
|
LESSOPEN="||-$xz -cdfqQ -- %s"
|
|
|
|
elif test "$VER" -ge 429; then
|
2009-08-09 18:22:12 +00:00
|
|
|
# less 429 or later: LESSOPEN pipe will be used on
|
|
|
|
# standard input if $LESSOPEN begins with |-.
|
2022-11-11 10:23:58 +00:00
|
|
|
LESSOPEN="|-$xz -cdfqQ -- %s"
|
2009-08-09 18:22:12 +00:00
|
|
|
else
|
2022-11-11 10:23:58 +00:00
|
|
|
LESSOPEN="|$xz -cdfqQ -- %s"
|
2009-08-09 18:22:12 +00:00
|
|
|
fi
|
2024-02-09 21:00:05 +00:00
|
|
|
|
|
|
|
SHOW_PREPROC_ERRORS=
|
|
|
|
if test "$VER" -ge 632; then
|
|
|
|
SHOW_PREPROC_ERRORS=--show-preproc-errors
|
|
|
|
fi
|
|
|
|
|
2009-07-05 19:25:17 +00:00
|
|
|
export LESSMETACHARS LESSOPEN
|
|
|
|
|
2024-02-09 21:00:05 +00:00
|
|
|
exec less $SHOW_PREPROC_ERRORS "$@"
|