From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on finch.gentoo.org X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=DATE_IN_PAST_12_24, DKIM_ADSP_NXDOMAIN,DMARC_MISSING,INVALID_DATE,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=no autolearn_force=no version=4.0.0 Received: from cicero0.cybercity.dk ([212.242.40.52]) by cvs.gentoo.org with esmtp (Exim 3.30 #1) id 15fr60-0002cJ-00 for gentoo-dev@cvs.gentoo.org; Sat, 08 Sep 2001 17:01:04 -0600 Received: from usr00.netlink.se (usr00.netlink.se [212.242.41.186]) by cicero0.cybercity.dk (Postfix) with ESMTP id C7775102A1B for ; Sun, 9 Sep 2001 01:00:37 +0200 (CEST) Received: from post.netlink.se (IDENT:mogge@port122.cvx1-sto.ppp.netlink.se [62.66.4.123]) by usr00.netlink.se (8.9.3/8.9.3) with ESMTP id BAA74022 for ; Sun, 9 Sep 2001 01:02:02 +0200 (CEST) (envelope-from sft3905@post.netlink.se) Message-ID: <3B9AA313.5090001@post.netlink.se> From: Morgan Christiansson User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.3) Gecko/20010803 X-Accept-Language: en-us MIME-Version: 1.0 To: gentoo-dev@cvs.gentoo.org Subject: Re: [gentoo-dev] Using less with compressed docs -- tip! References: <20010908164251.A25155@emt-p.org> Content-Type: multipart/mixed; boundary="------------040604090601080608060601" Sender: gentoo-dev-admin@cvs.gentoo.org Errors-To: gentoo-dev-admin@cvs.gentoo.org X-BeenThere: gentoo-dev@cvs.gentoo.org X-Mailman-Version: 2.0 Precedence: bulk Reply-To: gentoo-dev@cvs.gentoo.org X-Reply-To: mog@linux.nu List-Help: List-Post: List-Subscribe: , List-Id: Gentoo Linux development list List-Unsubscribe: , List-Archive: Date: Sat Sep 8 17:02:01 2001 X-Original-Date: Sun, 09 Sep 2001 01:00:35 +0200 X-Archives-Salt: 2085d47b-eb7e-4c01-a5d0-f7ae850fc7c3 X-Archives-Hash: 4f3d17783ef19dd834a6cc52a8f39b82 This is a multi-part message in MIME format. --------------040604090601080608060601 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Redhat has a shell-script called /usr/bin/zless: #!/bin/sh /bin/zcat "$@" | /usr/bin/less (zcat is hard-linked to gzip and gunzip) /usr/bin/zmore also exists and is the same but has a much more complicated shell script. It sets some terminal options and stuff. I attached some files there are a bunch more too. These are the executables in redhats gzip package. /bin/gunzip /bin/gzip /bin/zcat /usr/bin/gunzip /usr/bin/gzexe /usr/bin/gzip /usr/bin/zcmp /usr/bin/zdiff /usr/bin/zegrep /usr/bin/zfgrep /usr/bin/zforce /usr/bin/zgrep /usr/bin/zless /usr/bin/zmore /usr/bin/znew Ben Beuchler wrote: >Gentoo, by default, compresses any documetation installed by a program. Or so >it appears, anyway. Viewing these files transparently is pretty easy. First, >create a script like this: > >---------- >#!/bin/sh > >case "$1" in > *.gz) gunzip -c $1 2>/dev/null > ;; >esac >---------- > >And put it somewhere easily accessible, like /usr/local/bin/lesspipe.sh. > >Now do this: > >export LESSOPEN="|/usr/local/bin/lesspipe.sh %s" > >You'll probably want to stick that in /etc/profile or something. Now if you >try to use less top open a .gz file, it will work transparently. > >-Ben > --------------040604090601080608060601 Content-Type: text/plain; name="zless" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="zless" #!/bin/sh /bin/zcat "$@" | /usr/bin/less --------------040604090601080608060601 Content-Type: text/plain; name="zmore" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="zmore" #!/bin/sh PATH="/bin:$PATH"; export PATH if test "`echo -n a`" = "-n a"; then # looks like a SysV system: n1=''; n2='\c' else n1='-n'; n2='' fi oldtty=`stty -g 2>/dev/null` if stty -cbreak 2>/dev/null; then cb='cbreak'; ncb='-cbreak' else # 'stty min 1' resets eof to ^a on both SunOS and SysV! cb='min 1 -icanon'; ncb='icanon eof ^d' fi if test $? -eq 0 -a -n "$oldtty"; then trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15 else trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15 fi if test $# = 0; then if test -t 0; then echo usage: zmore files... 1>&2 exit 1 else gzip -cdfq | eval ${PAGER-more} fi else FIRST=1 for FILE do if test $FIRST -eq 0; then echo $n1 "--More--(Next file: $FILE)$n2" stty $cb -echo 2>/dev/null ANS=`dd bs=1 count=1 2>/dev/null` stty $ncb echo 2>/dev/null echo " " if test "$ANS" = 'e' -o "$ANS" = 'q'; then exit fi fi if test "$ANS" != 's'; then echo "------> $FILE <------" gzip -cdfq "$FILE" | eval ${PAGER-more} fi if test -t; then FIRST=0 fi done fi --------------040604090601080608060601 Content-Type: text/plain; name="zgrep" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="zgrep" #!/bin/sh # zgrep -- a wrapper around a grep program that decompresses files as needed # Adapted from a version sent by Charles Levert PATH="/bin:$PATH"; export PATH prog=`echo $0 | sed 's|.*/||'` case "$prog" in *egrep) grep=${EGREP-egrep} ;; *fgrep) grep=${FGREP-fgrep} ;; *) grep=${GREP-grep} ;; esac pat="" while test $# -ne 0; do case "$1" in -e | -f) opt="$opt $1"; shift; pat="$1" if test "$grep" = grep; then # grep is buggy with -e on SVR4 grep=egrep fi;; -A | -B) opt="$opt $1 $2"; shift;; -*) opt="$opt $1";; *) if test -z "$pat"; then pat="$1" else break; fi;; esac shift done if test -z "$pat"; then echo "grep through gzip files" 1>&2 echo "usage: $prog [grep_options] pattern [files]" 1>&2 exit 1 fi list=0 silent=0 op=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'` case "$op" in *l*) list=1 esac case "$op" in *h*) silent=1 esac if test $# -eq 0; then gzip -cdfq | $grep $opt "$pat" exit $? fi res=0 trap break SIGPIPE for i do if test $list -eq 1; then gzip -cdfq "$i" | $grep $opt "$pat" > /dev/null && echo $i r=$? elif test $# -eq 1 -o $silent -eq 1; then gzip -cdfq "$i" | $grep $opt "$pat" r=$? else gzip -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${i}:|" r=$? fi test "$r" -ne 0 && res="$r" echo done trap - SIGPIPE exit $res --------------040604090601080608060601--