Trying to use zless on stdin doesn't currently work:
$ echo foo | gzip - > foo.gz
$ zless < foo.gz
<see compressed data>
Lift some code from xzless and use the pipe feature of newer less
versions so this does work as expected.
Reported-by: Jeroen Roovers <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
---
zless.in | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/zless.in b/zless.in
index 4152017..8f75e6c 100644
--- a/zless.in
+++ b/zless.in
@@ -53,5 +53,13 @@ if test "${LESSMETACHARS+set}" != set; then
export LESSMETACHARS
fi
-LESSOPEN="|gzip -cdfq -- %s"; export LESSOPEN
+pipechar=""
+if test "$(less -V | { read ver && echo ${ver#less }; })" -ge 429; then
+ # less 429 or later: LESSOPEN pipe will be used on
+ # standard input if $LESSOPEN begins with |-.
+ pipechar="-"
+fi
+LESSOPEN="|${pipechar}gzip -cdfq -- %s"
+export LESSOPEN
+
exec less "$@"
--
1.7.6.1