On Sat, Jan 15, 2022 at 10:55:00PM +0100, наб wrote:
> Attached, you'll find patches, applying to less-590-1,
> that improve consistency, fix some bugs, and rewrite the manual.

If I had more than two functional brain-cells I wouldn't've forgotten to
actually attach them; soz.

Please consider the patches below :)

наб
Date: Sat, 15 Jan 2022 02:58:08 +0100
From: наб <nabijaczlew...@nabijaczleweli.xyz>
Subject: lesspipe: modernise

This patch applies the following trivial transformations:
  * replaces all `s with $(s
  * replaces [ -x `which CMD` ] (???) with command -v CMD >/dev/null
    (command -v is now in base XSH;
     which is undergoing a Debian-wide pruning and spews errors
     (though those are swallowed by the 2>/dev/null))
  * properly escapes escapes which are meant to be escapes but aren't
    (e.g. in iso_list)
  * wraps variable subsititutions in ""s
  * drops needless TMPDIR and umask
    for superfluous mktemp instrumentation
  * makes redirects consistently unspaced and at EOL
  * fixes all space indents
  * simplifies BASENAME and FULLPATH,
    as directed by "please send me a patch"
  * reformats the case entries for consistency:
      1. just compressor/just archiver as
           if CMD; then CMD $1
           else echo no CMD; fi ;;
      2. pipeline as
           if CMD; then
              CMD $1 | tar tvvf -
           else echo no CMD; fi ;;
      3. others left as-were
  * and fixes spurious end-of-sentence in lesspipe.1

---
debian/lesspipe   +79 -108
debian/lesspipe.1 +1  -1

--- less-590.orig/debian/lesspipe
+++ less-590/debian/lesspipe
@@ -17,23 +17,22 @@
 # throughout the code.  If you don't want lessfile to be called that,
 # you'll need to change the LESSFILE envar below.
 #
-# Usage: eval `lessfile`  or eval `lesspipe`
+# Usage: eval "$(lessfile)"  or eval "$(lesspipe)"
 #
 # less passes in:
 #    $1  filename to be viewed with less  (used by LESSOPEN)
 # and possibly (if used by lessfile)
 #    $2  filename that was created during LESSOPEN
 
-TMPDIR=${TMPDIR:-/tmp}
 CONFIGDIR=${XDG_CONFIG_HOME:-~/.config}
-BASENAME=`basename $0`
+BASENAME=${0##*/}
 LESSFILE=lessfile
 
 # Helper function to list contents of ISO files (CD images)
 iso_list() {
 	isoinfo -d -i "$1"
-	isoinfo -d -i "$1" | grep -q ^Rock\.Ridge && iiopts="$iiopts -R"
-	isoinfo -d -i "$1" | grep -q ^Joliet && iiopts="$iiopts -J"
+	isoinfo -d -i "$1" | grep -q '^Rock\.Ridge' && iiopts="$iiopts -R"
+	isoinfo -d -i "$1" | grep -q '^Joliet' && iiopts="$iiopts -J"
 	echo
 	isoinfo -f $iiopts -i "$1"
 }
@@ -47,12 +46,11 @@ if [ $# -eq 1 ] ; then
 	fi
 
 	# generate filename for possible use by lesspipe
-	umask 077
-	if [ $BASENAME = $LESSFILE ]; then
-		TMPFILE=`mktemp -p $TMPDIR lessfXXXXXX`
+	if [ "$BASENAME" = "$LESSFILE" ]; then
+		TMPFILE=$(mktemp -t lessfXXXXXX)
 		if [ -z "$TMPFILE" ]; then
-			echo >&2 "TMPFILE variable is empty. Exiting"
-		exit 1
+			echo "TMPFILE variable is empty. Exiting" >&2
+			exit 1
 		fi
 	fi
 
@@ -65,17 +63,17 @@ if [ $# -eq 1 ] ; then
 			USERFILTER=~/.lessfilter
 		fi
 		if [ -n "$USERFILTER" ]; then
-			if [ $BASENAME = $LESSFILE ]; then
-				"$USERFILTER" "$1" > $TMPFILE
+			if [ "$BASENAME" = "$LESSFILE" ]; then
+				"$USERFILTER" "$1" >"$TMPFILE"
 				if [ $? -eq 0 ]; then
-					if [ -s $TMPFILE ]; then
-						echo $TMPFILE
+					if [ -s "$TMPFILE" ]; then
+						echo "$TMPFILE"
 					else
-						rm -f $TMPFILE
+						rm -f "$TMPFILE"
 					fi
 					exit 0
 				else
-					rm -f $TMPFILE
+					rm -f "$TMPFILE"
 				fi
 			else
 				"$USERFILTER" "$1" && exit 0
@@ -83,29 +81,29 @@ if [ $# -eq 1 ] ; then
 		fi
 
 		# possibly redirect stdout to a file for lessfile
-		if [ $BASENAME = $LESSFILE ]; then exec > $TMPFILE; fi
+		if [ "$BASENAME" = "$LESSFILE" ]; then exec >"$TMPFILE"; fi
 
 		# Decode file for less
-		case `echo "$1" | tr '[:upper:]' '[:lower:]'` in
+		case "$(echo "$1" | tr '[:upper:]' '[:lower:]')" in
 			*.a)
-				if [ -x "`which ar`" ]; then ar tv "$1"
+				if command -v ar >/dev/null; then ar tv "$1"
 				else echo "No ar available"; fi ;;
 
 			*.arj)
-				if [ -x "`which unarj`" ]; then unarj l "$1"
+				if command -v unarj >/dev/null; then unarj l "$1"
 				else echo "No unarj available"; fi ;;
 
 			*.tar.bz2)
-				if [ -x "`which bunzip2`" ]; then
+				if command -v bunzip2 >/dev/null; then
 					bunzip2 -dc "$1" | tar tvvf -
 				else echo "No bunzip2 available"; fi ;;
 
 			*.bz)
-				if [ -x "`which bunzip`" ]; then bunzip -c "$1"
+				if command -v bunzip >/dev/null; then bunzip -c "$1"
 				else echo "No bunzip available"; fi ;;
 
 			*.bz2)
-				if [ -x "`which bunzip2`" ]; then bunzip2 -dc "$1"
+				if command -v bunzip2 >/dev/null; then bunzip2 -dc "$1"
 				else echo "No bunzip2 available"; fi ;;
 
 			*.deb|*.udeb|*.ddeb|*.ipk)
@@ -115,20 +113,20 @@ if [ $# -eq 1 ] ; then
 				;;
 
 			*.doc)
-				if [ -x "`which catdoc`" ]; then
+				if command -v catdoc >/dev/null; then
 					catdoc "$1"
 				else
 					# no catdoc, read normally if file is text.
-					if ( file "$1" | grep ASCII 2>/dev/null >/dev/null); then
+					if file "$1" | grep ASCII 2>/dev/null >/dev/null; then
 						cat "$1"
 					else
-						echo "No catdoc available";
+						echo "No catdoc available"
 					fi
 				fi
 				;;
 
 			*.egg)
-				if [ -x "`which unzip`" ]; then
+				if command -v unzip >/dev/null; then
 					unzip -p "$1" EGG-INFO/PKG-INFO | \
 						sed '/^Description:/,/^\S/{/^Description:/d; /^\S/b; d}'
 					echo
@@ -139,7 +137,7 @@ if [ $# -eq 1 ] ; then
 				;;
 
 			*.gif|*.jpeg|*.jpg|*.pcd|*.png|*.tga|*.tiff|*.tif)
-				if [ -x "`which identify`" ]; then
+				if command -v identify >/dev/null; then
 					identify "$1"
 				else
 					echo "No identify available"
@@ -148,7 +146,7 @@ if [ $# -eq 1 ] ; then
 				;;
 
 			*.iso)
-				if [ -x "`which isoinfo`" ]; then iso_list "$1"
+				if command -v isoinfo >/dev/null; then iso_list "$1"
 				else
 					echo "No isoinfo available"
 					echo "Install mkisofs to view ISO images"
@@ -156,8 +154,8 @@ if [ $# -eq 1 ] ; then
 				;;
 
 			*.bin|*.raw)
-				if [ -x "`which isoinfo`" ]; then
-					file "$1" | grep -q ISO\.9660 && iso_list "$1"
+				if command -v isoinfo >/dev/null; then
+					file "$1" | grep -qF 'ISO.9660' && iso_list "$1"
 				else
 					echo "No isoinfo available"
 					echo "Install mkisofs to view ISO images"
@@ -165,105 +163,81 @@ if [ $# -eq 1 ] ; then
 				;;
 
 			*.lha|*.lzh)
-				if [ -x "`which lha`" ]; then lha v "$1"
+				if command -v lha >/dev/null; then lha v "$1"
 				else echo "No lha available"; fi ;;
 
 			*.tar.lz|*.tlz)
-				if [ -x "`which lzip`" ]; then
+				if command -v lzip >/dev/null; then
 					lzip -dc "$1" | tar tvvf -
-				elif [ -x "`which lunzip`" ]; then
+				elif command -v lunzip >/dev/null; then
 					lunzip -dc "$1" | tar tvvf -
 				else echo "No lzip or lunzip available"; fi ;;
 
 			*.lz)
-				if [ -x "`which lzip`" ]; then lzip -dc "$1"
-				elif [ -x "`which lunzip`" ]; then lunzip -dc "$1"
+				if command -v lzip >/dev/null; then lzip -dc "$1"
+				elif command -v lunzip >/dev/null; then lunzip -dc "$1"
 				else echo "No lzip or lunzip available"; fi ;;
 
 			*.tar.lzma)
-				if [ -x "`which lzma`" ]; then
+				if command -v lzma >/dev/null; then
 					lzma -dc "$1" | tar tfvv -
-				else
-					echo "No lzma available"
-				fi
-				;;
+				else echo "No lzma available"; fi ;;
 
 			*.lzma)
-				if [ -x "`which lzma`" ]; then
-					lzma -dc "$1"
-				else
-					echo "No lzma available"
-				fi
-				;;
+				if command -v lzma >/dev/null; then lzma -dc "$1"
+				else echo "No lzma available"; fi ;;
 
 			*.pdf)
-				if [ -x "`which pdftotext`" ]; then pdftotext -layout "$1" -
+				if command -v pdftotext >/dev/null; then pdftotext -layout "$1" -
 				else echo "No pdftotext available"; fi ;;
 
 			*.rar|*.r[0-9][0-9])
-				if [ -x "`which rar`" ]; then rar v "$1"
-				elif [ -x "`which unrar`" ]; then unrar v "$1"
+				if command -v rar >/dev/null; then rar v "$1"
+				elif command -v unrar >/dev/null; then unrar v "$1"
 				else echo "No rar or unrar available"; fi ;;
 
 			*.rpm)
-				if [ -x "`which rpm`" ]; then
+				if command -v rpm >/dev/null; then
 					echo "$1:"; rpm -q -i -p "$1"
 					echo
 					echo '*** Contents:'
 					rpm -q -l -p "$1"
 				else echo "rpm isn't available, no query on rpm package possible"; fi ;;
 
-                        *.snap)
-                            if [ -x "`which snap`" ]; then snap info "$1"; fi
-                            if [ -x "`which unsquashfs`" ]; then
-                                echo
-                                echo '*** Contents:'; unsquashfs -ll -d '' "$1" 
-                            else echo "No unsquashfs available"; fi ;;
-                        
+			*.snap)
+				if command -v snap >/dev/null; then snap info "$1"; fi
+				if command -v unsquashfs >/dev/null; then
+					echo
+					echo '*** Contents:'; unsquashfs -ll -d '' "$1"
+				else echo "No unsquashfs available"; fi ;;
+
 			*.tar.gz|*.tgz|*.tar.z|*.tar.dz)
 				tar tzvf "$1" --force-local
 				;;
 
 			*.tar.xz|*.txz)
-				if [ -x "`which xz`" ]; then
+				if command -v xz >/dev/null; then
 					xz -dc "$1" | tar tfvv -
-				else
-					echo "No xz available"
-				fi
-				;;
+				else echo "No xz available"; fi ;;
 
 			*.tar.zst|*.tzst)
-				if [ -x "`which zstd`" ]; then
+				if command -v zstd >/dev/null; then
 					zstd -qdc "$1" | tar tfvv -
-				else
-					echo "No zstd available"
-				fi
-				;;
+				else echo "No zstd available"; fi ;;
 
 			*.whl)
-				if [ -x "`which unzip`" ]; then
+				if command -v unzip >/dev/null; then
 					unzip -p "$1" '*.dist-info/METADATA' | sed '/^$/q'
 					unzip -v "$1"
-				else
-		 			echo "No unzip available"
-				fi
-				;;
+				else echo "No unzip available"; fi ;;
 
 			*.xz)
-				if [ -x "`which xz`" ]; then
-					xz -dc "$1"
-				else
-					echo "No xz available"
-				fi
-				;;
+				if command -v xz >/dev/null; then xz -dc "$1"
+				else echo "No xz available"; fi ;;
 
 			*.zst)
-				if [ -x "`which zstd`" ]; then
-					zstd -qdc "$1"
-				else
-					echo "No zstd available"
-				fi
-				;;
+				if command -v zstd >/dev/null; then zstd -qdc "$1"
+				else echo "No zstd available"; fi ;;
 
 			# Note that this is out of alpha order so that we don't catch
 			# the gzipped tar files.
@@ -271,33 +245,32 @@ if [ $# -eq 1 ] ; then
 				gzip -dc "$1" ;;
 
 			*.tar)
-				tar tvf "$1" --force-local
-				;;
+				tar tvf "$1" --force-local ;;
 
 			*.jar|*.war|*.ear|*.xpi|*.zip)
-				if [ -x "`which unzip`" ]; then unzip -v "$1";
-				elif [ -x "`which miniunzip`" ]; then miniunzip -l "$1";
-				elif [ -x "`which miniunz`" ]; then miniunz -l "$1";
-				else echo "No unzip, miniunzip or miniunz available"; fi ;;
+				if command -v unzip >/dev/null; then unzip -v "$1";
+				elif command -v miniunzip >/dev/null; then miniunzip -l "$1";
+				elif command -v miniunz >/dev/null; then miniunz -l "$1";
+				else echo "No unzip, miniunzip, or miniunz available"; fi ;;
 
 			*.7z)
-				if [ -x "`which 7za`" ]; then 7za l "$1";
-                                elif [ -x "`which 7zr`" ]; then 7zr l "$1";
+				if command -v 7za >/dev/null; then 7za l "$1";
+				elif command -v 7zr >/dev/null; then 7zr l "$1";
 				else echo "No 7za or 7zr available"; fi ;;
 
 			*.zoo)
-				if [ -x "`which zoo`" ]; then zoo v "$1";
-				elif [ -x "`which unzoo`" ]; then unzoo -l "$1";
+				if command -v zoo >/dev/null; then zoo v "$1";
+				elif command -v unzoo >/dev/null; then unzoo -l "$1";
 				else echo "No unzoo or zoo available"; fi ;;
 
 		esac
 	) 2>/dev/null
 
-	if [ $BASENAME = $LESSFILE ]; then
-		if [ -s $TMPFILE ]; then
-			echo $TMPFILE
+	if [ "$BASENAME" = "$LESSFILE" ]; then
+		if [ -s "$TMPFILE" ]; then
+			echo "$TMPFILE"
 		else
-			rm -f $TMPFILE
+			rm -f "$TMPFILE"
 		fi
 	fi
 
@@ -306,10 +279,10 @@ elif [ $# -eq 2 ] ; then
 	# we were called as LESSCLOSE
 	# delete the file created if we were lessfile
 	#
-	if [ $BASENAME = $LESSFILE ]; then
+	if [ "$BASENAME" = "$LESSFILE" ]; then
 		if [ -n "$BASH" ]; then
 			if [ ! -O "$2" ]; then
-				echo "Error in deleting $2" > /dev/tty
+				echo "Error in deleting $2" >/dev/tty
 				exit 1
 			fi
 		fi
@@ -317,7 +290,7 @@ elif [ $# -eq 2 ] ; then
 		if [ -f "$2" ]; then
 			rm -f "$2"
 		else
-			echo "Error in deleting $2" > /dev/tty
+			echo "Error in deleting $2" >/dev/tty
 		fi
 	fi
 
@@ -331,13 +304,11 @@ elif [ $# -eq 0 ] ; then
 	#
 
 	# first determine the full path of lessfile/lesspipe
-	# if you can determine a better way to do this, send me a patch, I've
-	# not shell-scripted for many a year.
-	FULLPATH=`cd \`dirname $0\`;pwd`/$BASENAME
+	FULLPATH=$(realpath "$0")
 
 	case "$SHELL" in
 		*csh)
-			if [ $BASENAME = $LESSFILE ]; then
+			if [ "$BASENAME" = "$LESSFILE" ]; then
 				echo "setenv LESSOPEN \"$FULLPATH %s\";"
 				echo "setenv LESSCLOSE \"$FULLPATH %s %s\";"
 			else
@@ -346,7 +317,7 @@ elif [ $# -eq 0 ] ; then
 			fi
 			;;
 		*)
-			if [ $BASENAME = $LESSFILE ]; then
+			if [ "$BASENAME" = "$LESSFILE" ]; then
 				echo "export LESSOPEN=\"$FULLPATH %s\";"
 				echo "export LESSCLOSE=\"$FULLPATH %s %s\";"
 			else
@@ -362,6 +333,6 @@ elif [ $# -eq 0 ] ; then
 	#echo "# calling less."
 
 else
-	echo "Usage: eval \`$BASENAME\`"
+	echo "Usage: eval \"\$($BASENAME)\""
 	exit
 fi
--- less-590.orig/debian/lesspipe.1
+++ less-590/debian/lesspipe.1
@@ -47,7 +47,7 @@ will then delete the file.  This means that the process has to finish before
 you see it, but you get nice percentages (N%) up front.
 .
 .SH USAGE
-Just put one of the following two commands in your login script (e.g.
+Just put one of the following two commands in your login script (e.g.\&
 ~/.bash_profile):
 .PP
   eval "$(lessfile)"
Date: Sat, 15 Jan 2022 04:40:25 +0100
From: наб <nabijaczlew...@nabijaczleweli.xyz>
Subject: lesspipe.1: update with all current entries, fold existing

The existing entries weren't all consistently folded into ,-separated
lines, and not all cases were reflected
---
debian/lesspipe.1 +9 -10
debian/lesspipe   +1 -1

--- less-590.orig2/debian/lesspipe.1
+++ less-590/debian/lesspipe.1
@@ -66,27 +66,26 @@ This is a list of currently supported extensions
   *.tar.bz2
   *.bz
   *.bz2
-  *.deb, *.udeb, *.ddeb
+  *.deb, *.udeb, *.ddeb, *.ipk
   *.doc
   *.egg
   *.gif, *.jpeg, *.jpg, *.pcd, *.png, *.tga, *.tiff, *.tif
-  *.iso, *.raw, *.bin
+  *.iso, *.bin, *.raw
   *.lha, *.lzh
-  *.tar.lz, *.tlz
-  *.lz
+  *.tar.lz, *.tlz, *.lz
   *.7z
   *.pdf
   *.rar, *.r[0-9][0-9]
   *.rpm
-  *.tar.gz, *.tgz, *.tar.z, *.tar.dz
-  *.gz, *.z, *.dz
+  *.snap
   *.tar
-  *.tar.xz, *.xz
+  *.tar.gz, *.tgz, *.tar.z, *.tar.dz, *.gz, *.z, *.dz
+  *.tar.lzma, *.lzma
+  *.tar.xz, *.txz, *.xz
+  *.tar.zst, *.tzst, *.zst
   *.whl
-  *.jar, *.war, *.xpi, *.zip
+  *.jar, *.war, *.ear, *.xpi, *.zip
   *.zoo
-  *.tar.zst, *.tzst
-  *.zst
 .DE
 .SH USER DEFINED FILTERS
 It is possible to extend and overwrite the default
--- less-590.orig2/debian/lesspipe
+++ less-590/debian/lesspipe
@@ -83,7 +83,7 @@ if [ $# -eq 1 ] ; then
 		# possibly redirect stdout to a file for lessfile
 		if [ "$BASENAME" = "$LESSFILE" ]; then exec >"$TMPFILE"; fi
 
-		# Decode file for less
+		# Decode file for less; remember to document new entries in lesspipe.1!
 		case "$(echo "$1" | tr '[:upper:]' '[:lower:]')" in
 			*.a)
 				if command -v ar >/dev/null; then ar tv "$1"
Date: Sat, 15 Jan 2022 04:40:48 +0100
From: наб <nabijaczlew...@nabijaczleweli.xyz>
Subject: lesspipe.1: rewrite

The current manual was not only *extremely* weirdly formatted,
said .TH LESSOPEN 1 (???), but also kinda soupy (sorry)

Rewritten in mdoc, mandoc -Tlint clean

Example with actual, real, working code for .Z/uncompress

arj, bunzip, zoo, and miniunz no longer exist in Debian;
may it be prudent to remove them entirely?
---
debian/lesspipe   +3 -3
debian/lesspipe.1 rewritten 155 -> 141

--- less-590.orig3/debian/lesspipe
+++ less-590/debian/lesspipe
@@ -76,7 +76,7 @@ if [ $# -eq 1 ] ; then
 					rm -f "$TMPFILE"
 				fi
 			else
-				"$USERFILTER" "$1" && exit 0
+				exec "$USERFILTER" "$1"
 			fi
 		fi
 
@@ -149,7 +149,7 @@ if [ $# -eq 1 ] ; then
 				if command -v isoinfo >/dev/null; then iso_list "$1"
 				else
 					echo "No isoinfo available"
-					echo "Install mkisofs to view ISO images"
+					echo "Install genisoimage to view ISO images"
 				fi
 				;;
 
@@ -158,7 +158,7 @@ if [ $# -eq 1 ] ; then
 					file "$1" | grep -qF 'ISO.9660' && iso_list "$1"
 				else
 					echo "No isoinfo available"
-					echo "Install mkisofs to view ISO images"
+					echo "Install genisoimage to view ISO images"
 				fi
 				;;
 
--- less-590.orig3/debian/lesspipe.1
+++ less-590/debian/lesspipe.1
@@ -1,155 +1,141 @@
-.TH LESSOPEN 1
-.\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection
-.\" other parms are allowed: see man(7), man(1)
-.SH NAME
-lessfile, lesspipe \- "input preprocessor" for  less.
-.SH SYNOPSIS
-.B lessfile, lesspipe
-.SH "DESCRIPTION"
-This manual page documents briefly the
-.IR lessfile ,
-and
-.I lesspipe
-commands.
-This manual page was written for the Debian GNU/Linux distribution
-because the input preprocessor scripts are provided by Debian GNU/Linux and
-are not part of the original program.
-.PP
-.I lessfile
+.Dd January 15, 2022
+.Dt LESSPIPE 1
+.Os
+.
+.Sh NAME
+.Nm lesspipe , lessfile
+.Nd less(1) input preprocessor
+.Sh SYNOPSIS
+.Nm eval Qq $ Ns Pq Cm lesspipe
+.Nm eval Qq $ Ns Pq Cm lessfile
+.
+.Sh DESCRIPTION
+.Nm
 and
-.I lesspipe
-are programs that can be used to modify the way the contents of a file are
-displayed in
-.I less.
-What this means is that
-.I less
-can automatically open
-up tar files, uncompress gzipped files, and even display something reasonable
-for graphics files.
-.PP
-.I lesspipe
-will toss the contents/info on STDOUT and
-.I less
-will read them
-as they come across.  This means that you do not have to wait for the
-decoding to finish before less shows you the file.  This also means that
-you will get a 'byte N' instead of an N% as your file position.  You can
-seek to the end and back to get the N% but that means you have to wait
-for the pipe to finish.
-.PP
-.I lessfile
-will toss the contents/info on a file which
-.I less
-will then
-read.  After you are done,
-.I lessfile
-will then delete the file.  This means that the process has to finish before
-you see it, but you get nice percentages (N%) up front.
+.Nm lessfile
+can be used to modify the way the contents of a file are displayed in
+.Xr less 1
+by acting as a filter: with their help,
+.Nm less
+can automatically open up
+.Xr tar 5
+files, uncompress
+.Xr gzip 1 Ns ped
+files, and even display something reasonable for images.
+.Pp
+.Nm
+provides its output to
+.Nm less
+via a pipe.
+This means that you do not have to wait for the
+decoding to finish before
+.Nm less
+shows you the file, but you will not see the total output length.
+.Pp
+.Nm lessfile
+stashes its output in a temporary file;
+this means that the entire input needs to be processed before anything is shown,
+but the total output length (and, hence, relative position) is available from the beginning.
+.
+.Ss File type recognition
+File types are recognized by their extensions; the following are supported:
+.Bl -column -compact -offset Ds ".gif, .jpeg, .jpg, .pcd, .png, .tga, .tiff, .tif" ".Xr unzip 1 , Xr miniunzip 1" "snap, squashfs-tools"
+.It Sy Extensions                                           Ta Sy Program                  Ta Sy Dependencies
+.It .a                                                      Ta Xr ar 1                     Ta
+.It .arj                                                    Ta Xr unarj 1                  Ta (no longer in Debian)
+.It .bz                                                     Ta Xr bunzip 1                 Ta (no longer in Debian)
+.It .deb , .udeb , .ddeb , .ipk                             Ta Xr dpkg 1 , Xr dpkg-deb 1   Ta
+.It .gif , .jpeg , .jpg , .pcd , .png , .tga , .tiff , .tif Ta Xr identify 1               Ta imagemagick
+.It .iso , .bin , .raw                                      Ta Xr isoinfo 1                Ta genisoimage
+.It .lha , .lzh                                             Ta Xr lha 1                    Ta lhasa
+.It .pdf                                                    Ta Xr pdftotext 1              Ta poppler-utils
+.It .rar , .r[0-9][0-9]                                     Ta Xr rar 1 , Xr unrar 1       Ta rar , unrar
+.It .rpm                                                    Ta Xr rpm 8                    Ta rpm
+.It .snap                                                   Ta Xr snap 8 , Xr unsquashfs 1 Ta snap , squashfs-tools
+.It .tar                                                    Ta Xr tar 1                    Ta
+.It .tar.gz , .tgz , .tar.z , .tar.dz , .gz , .z , .dz      Ta Xr gzip 1                   Ta
+.It .tar.lz , .tlz , .lz                                    Ta Xr lzip 1 , Xr lunzip 1     Ta lzip , lunzip
+.It .tar.xz , .txz , .xz                                    Ta Xr xz 1                     Ta xz-utils
+.It .tar.zst , .tzst , .zst                                 Ta Xr zstd 1                   Ta zstd
+.It .jar , .war , .ear , .xpi , .zip , .egg , .whl          Ta Xr unzip 1 , Xr miniunzip 1 Ta unzip , minizip
+.It .zoo                                                    Ta Xr zoo 1 , Xr unzoo 1       Ta (no longer in Debian)
+.El
 .
-.SH USAGE
-Just put one of the following two commands in your login script (e.g.\&
-~/.bash_profile):
-.PP
-  eval "$(lessfile)"
-.PP
+.Ss User-defined filters
+If
+.Ev $XDG_CONFIG_HOME Ns / Ns Nm lessfilter
 or
-.PP
-  eval "$(lesspipe)"
-.SH FILE TYPE RECOGNITION
-File types are recognized by their extensions.
-This is a list of currently supported extensions
-(grouped by the programs that handle them):
+.Pf ~/ Nm .lessfilter
+is executable, it'll be executed by
+.Nm
+with the file to process as the only argument:
+it must exit
+.Sy 0
+and write the output to the standard output stream if it handles that particular file,
+or exit
+.Pf non- Sy 0
+to fall back to
+.Nm
+handling.
+.Pp
+No special processing is required for
+.Nm lessfile
+\(em the standard output stream is tied to the temporary file in that case.
+.Pp
+An example filter:
+.Bd -literal -offset Ds
+#!/bin/sh
 
-.DS
-  *.a
-  *.arj
-  *.tar.bz2
-  *.bz
-  *.bz2
-  *.deb, *.udeb, *.ddeb, *.ipk
-  *.doc
-  *.egg
-  *.gif, *.jpeg, *.jpg, *.pcd, *.png, *.tga, *.tiff, *.tif
-  *.iso, *.bin, *.raw
-  *.lha, *.lzh
-  *.tar.lz, *.tlz, *.lz
-  *.7z
-  *.pdf
-  *.rar, *.r[0-9][0-9]
-  *.rpm
-  *.snap
-  *.tar
-  *.tar.gz, *.tgz, *.tar.z, *.tar.dz, *.gz, *.z, *.dz
-  *.tar.lzma, *.lzma
-  *.tar.xz, *.txz, *.xz
-  *.tar.zst, *.tzst, *.zst
-  *.whl
-  *.jar, *.war, *.ear, *.xpi, *.zip
-  *.zoo
-.DE
-.SH USER DEFINED FILTERS
-It is possible to extend and overwrite the default
-.I lesspipe
+.Ic case Qo Ar $1 Qc Ic in
+.Li "   " Pa *.Z )
+.Li "   " "   " Nm uncompress Fl dc Qq Ar $1
+        ;;
+.Li "   " Pa * )
+        # We don't handle this format.
+.Li "   " "   " Nm exit Li 1
+        ;;
+.Ic esac
+.Ed
+.
+.Sh USAGE
+Include one of the
+.Sx SYNOPSIS
+snippets in the login script
+.Pq Pa ~/.profile , No &c.\& .
+.
+.Sh SEE ALSO
+.Xr less 1
+.
+.Sh NOTES
+The input preprocessor scripts are provided by Debian GNU/Linux and
+are not part of the original program.
+.
+.Sh AUTHORS
+.An -nosplit
+This manual page was originally written by
+.An Thomas Schoepf Aq scho...@debian.org
+and re-written by
+.An наб Aq nabijaczlew...@nabijaczleweli.xyz
+for the Debian GNU/Linux system (but may be used by others).
+Most of the text used to have had been copied from a description written by
+.An Darren Stalder Aq to...@daft.com .
+.
+.Sh BUGS
+Sometimes
+.Nm less
+does not display the contents file you want to view,
+but the output of your login scripts
+.Pq Pa ~/.profile , ~/.bashrc , No &c.\& .
+This happens because
+.Nm less
+uses the current shell to run
+.Nm ,
 and
-.I lessfile
-input processor if you have specialized requirements. Create an executable
-program with the name
-.I .lessfilter
-and put it into your home directory. This can be a shell script or a binary
-program.
-
-.PP
-It is important that this program returns the correct exit code: return 0 if
-your filter handles the input, return 1 if the standard
-.I lesspipe/lessfile
-filter should handle the input.
-
-.PP
-Here is an example script:
-
-.DS
-  #!/bin/sh
-
-  case "$1" in
-      *.extension)
-          extension-handler "$1"
-          ;;
-      *)
-          # We don't handle this format.
-          exit 1
-  esac
-
-  # No further processing by lesspipe necessary
-  exit 0
-.DE
-
-.SH FILES
-.TP
-.I ~/.lessfilter
-Executable file that can do user defined processing. See section USER DEFINED
-FILTERS for more information.
-.SH BUGS
-.PP
-Sometimes, less does not display the contents file you want to view but output
-that is produced by your login scripts (~/.bashrc or ~/.bash_profile). This
-happens because less uses your current shell to run the lesspipe filter. Bash
-first looks for the variable $BASH_ENV in the environment expands its value
-and  uses the expanded value as the name of a file to read and execute. If
-this file produces any output less will display this. A way to solve this
-problem is to put the following lines on the top of your login script that
-produces output:
-
-.DS
-  if [ -z "$PS1" ]; then
-      exit
-  fi
-.DE
-
-This tests whether the prompt variable $PS1 is set and if it isn't (which is
-the case for non-interactive shells) it will exit the script.
-.SH "SEE ALSO"
-less(1)
-.SH AUTHOR
-This manual page was written by Thomas Schoepf <scho...@debian.org>,
-for the Debian GNU/Linux system (but may be used by others). Most of the
-text was copied from a description written by Darren Stalder <to...@daft.com>.
+.Xr bash 1
+sources the script specified in
+.Ev $BASH_ENV ,
+if any \(em if it produces any output,
+.Nm less
+will display it.
+The offending script will have to be silenced, for example by starting it with
+.D1 Nm \&[ Fl z Qo Ev $PS1 Qc Cm ]\& Li && Nm exit

Attachment: signature.asc
Description: PGP signature

Reply via email to