bug-gzip
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] zless: support compressed stdin


From: Mike Frysinger
Subject: [PATCH] zless: support compressed stdin
Date: Wed, 21 Dec 2011 14:54:06 -0500

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 <address@hidden>
Signed-off-by: Mike Frysinger <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]