summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--metadata/pkg_desc_index2
-rw-r--r--sys-apps/less/files/lesspipe-r1.sh (renamed from sys-apps/less/files/lesspipe.sh)36
-rw-r--r--sys-apps/less/less-563-r1.ebuild (renamed from sys-apps/less/less-563.ebuild)2
3 files changed, 23 insertions, 17 deletions
diff --git a/metadata/pkg_desc_index b/metadata/pkg_desc_index
index 74a13b27..a075608e 100644
--- a/metadata/pkg_desc_index
+++ b/metadata/pkg_desc_index
@@ -98,7 +98,7 @@ sci-geosciences/googleearth 7.1.8.3036-r3 7.3.0.3832-r3 7.3.2 7.3.3: A 3D interf
sci-mathematics/genius 1.0.21: Genius Mathematics Tool and the GEL Language
sci-mathematics/reduce 20141130-r3 20190413: A general-purpose computer algebra system
sys-apps/cpi 3.2: A wrapper for cp -i -a, making use of diff
-sys-apps/less 563: Excellent text file viewer, optionally with additional selection feature
+sys-apps/less 563-r1: Excellent text file viewer, optionally with additional selection feature
sys-apps/man 1.6g-r3: Standard commands to read man pages
sys-apps/openrc-wrapper 2.4: Use openrc init scripts with systemd or other init systems
sys-apps/paxopen 1.2: A wrapper script to set PAX kernel variables to an insecure/safe state
diff --git a/sys-apps/less/files/lesspipe.sh b/sys-apps/less/files/lesspipe-r1.sh
index 66078850..9dcfea1d 100644
--- a/sys-apps/less/files/lesspipe.sh
+++ b/sys-apps/less/files/lesspipe-r1.sh
@@ -1,11 +1,13 @@
#!/bin/bash
-#
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
# Preprocessor for 'less'. Used when this environment variable is set:
# LESSOPEN="|lesspipe %s"
# TODO: handle compressed files better
-[[ -n ${LESSDEBUG} ]] && set -x
+[[ -n ${LESSDEBUG+set} ]] && set -x
trap 'exit 0' PIPE
@@ -17,6 +19,7 @@ guesscompress() {
*.lzma) echo "unlzma -c" ;;
*.lzo) echo "lzop -dc" ;;
*.xz) echo "xzdec" ;;
+ *.zst) echo "zstdcat" ;;
*) echo "cat" ;;
esac
}
@@ -64,8 +67,9 @@ lesspipe() {
ls -alF -- "$1"
return
elif [[ ! -f $1 ]] ; then
- stat "$1"
- return
+ # Only return if the stat passes. This is needed to handle pseudo
+ # arguments like URIs.
+ stat -- "$1" && return
fi
case "${match}" in
@@ -76,6 +80,7 @@ lesspipe() {
*.[0-9n].gz|*.man.gz|\
*.[0-9n].lzma|*.man.lzma|\
*.[0-9n].xz|*.man.xz|\
+ *.[0-9n].zst|*.man.zst|\
*.[0-9][a-z].gz|*.[0-9][a-z].gz)
local out=$(${DECOMPRESSOR} -- "$1" | file -)
case ${out} in
@@ -104,10 +109,11 @@ lesspipe() {
*.doc) antiword "$1" || catdoc "$1" ;;
*.rtf) unrtf --nopict --text "$1" ;;
*.conf|*.txt|*.log) ;; # force less to work on these directly #150256
+ *.json) python -mjson.tool "$1" ;;
### URLs ###
- ftp://*|http://*|*.htm|*.html)
- for b in links2 links lynx ; do
+ ftp://*|http://*|https://|*.htm|*.html)
+ for b in elinks links2 links lynx ; do
${b} -dump "$1" && exit 0
done
html2text -style pretty "$1"
@@ -115,23 +121,24 @@ lesspipe() {
### Tar files ###
*.tar|\
- *.tar.bz2|*.tar.bz|*.tar.gz|*.tar.z|\
+ *.tar.bz2|*.tar.bz|*.tar.gz|*.tar.z|*.tar.zst|\
*.tar.lz|*.tar.tlz|\
*.tar.lzma|*.tar.xz)
${DECOMPRESSOR} -- "$1" | tar tvvf -;;
*.tbz2|*.tbz|*.tgz|*.tlz|*.txz)
- lesspipe "$1" "$1".tar.${1##*.t} ;;
+ lesspipe "$1" "$1.tar.${1##*.t}" ;;
### Misc archives ###
*.bz2|\
*.gz|*.z|\
+ *.zst|\
*.lz|\
*.lzma|*.xz) ${DECOMPRESSOR} -- "$1" ;;
*.rpm) rpm -qpivl --changelog -- "$1" || rpm2tar -O "$1" | tar tvvf -;;
*.cpi|*.cpio) cpio -itv < "$1" ;;
*.ace) unace l "$1" ;;
*.arc) arc v "$1" ;;
- *.arj) unarj l -- "$1" ;;
+ *.arj) arj l -- "$1" || unarj l "$1" ;;
*.cab) cabextract -l -- "$1" ;;
*.lha|*.lzh) lha v "$1" ;;
*.zoo) zoo -list "$1" || unzoo -l "$1" ;;
@@ -207,7 +214,7 @@ lesspipe() {
*)
case $(( recur++ )) in
# Maybe we didn't match due to case issues ...
- 0) lesspipe "$1" "$(echo $1 | LC_ALL=C tr '[:upper:]' '[:lower:]')" ;;
+ 0) lesspipe "$1" "$(echo "$1" | LC_ALL=C tr '[:upper:]' '[:lower:]')" ;;
# Maybe we didn't match because the file is named weird ...
1) lesspipe_file "$1" ;;
@@ -241,12 +248,12 @@ lesspipe() {
esac
}
-if [[ -z $1 ]] ; then
+if [[ $# -eq 0 ]] ; then
echo "Usage: lesspipe <file>"
elif [[ $1 == "-V" || $1 == "--version" ]] ; then
cat <<-EOF
lesspipe (git)
- Copyright 2001-2016 Gentoo Foundation
+ Copyright 1999-2019 Gentoo Authors
Mike Frysinger <vapier@gentoo.org>
(with plenty of ideas stolen from other projects/distros)
@@ -275,7 +282,6 @@ elif [[ $1 == "-h" || $1 == "--help" ]] ; then
EOF
else
recur=0
- [[ -n ${LESSDEBUG} ]] \
- && lesspipe "$1" \
- || lesspipe "$1" 2> /dev/null
+ [[ -z ${LESSDEBUG+set} ]] && exec 2>/dev/null
+ lesspipe "$1"
fi
diff --git a/sys-apps/less/less-563.ebuild b/sys-apps/less/less-563-r1.ebuild
index e4191034..3aabe594 100644
--- a/sys-apps/less/less-563.ebuild
+++ b/sys-apps/less/less-563-r1.ebuild
@@ -65,7 +65,7 @@ src_install() {
local a
default
- newbin "${FILESDIR}"/lesspipe.sh lesspipe
+ newbin "${FILESDIR}"/lesspipe-r1.sh lesspipe
if use original-gentoo
then a="-R -M --shift 5"