Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 217954 - sys-apps/less: add user-override var to lesspipe.sh
Summary: sys-apps/less: add user-override var to lesspipe.sh
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-16 13:56 UTC by d_m
Modified: 2008-04-18 19:58 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to use $LESSIGNORE (lesspipe.patch,371 bytes, patch)
2008-04-16 13:58 UTC, d_m
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description d_m 2008-04-16 13:56:21 UTC
Currently, lesspipe.sh has a hardcoded list of file types which are displayed via external programs, and the user's only options are to disable lesspipe.sh, roll their own, or use -L selectively in order to avoid the default behavior (the example from the forums is viewing HTML source rather than rendering HTML via links/lynx).

This patch allows users to define LESSIGNORE, a colon-delimited list of extensions which should not be rendered. It's an added two-lines which doesn't touch any of the existing behavior.

I will attach a patch.

Reproducible: Always
Comment 1 d_m 2008-04-16 13:58:33 UTC
Created attachment 149940 [details, diff]
Patch to use $LESSIGNORE

This is the patch that I posted in this forum thread:

http://forums.gentoo.org/viewtopic-t-688322-highlight-.html
Comment 2 SpanKY gentoo-dev 2008-04-16 16:34:14 UTC
two lines which execute external programs ;).  it also doesnt seem to handle multi-dotted things such as ".tar.gz"

perhaps this:
for ignore in ${LESSIGNORE//:/ } ; do
    [[ ${match} == *.${ignore} ]] && exit 0
done
Comment 3 SpanKY gentoo-dev 2008-04-16 17:26:35 UTC
another alternative: add a ~/.lessfilter that does:
#!/bin/sh
echo "$1" | grep '\.html$' && exit 1
exit 0
Comment 4 d_m 2008-04-16 18:20:54 UTC
Haha, thanks for giving me a bash-only version. I'm not as familiar with the various splitting/matching features in bash, so I figured I'd write something that works.

Your first suggestion seems the best to me. Do you think it's possible to get that merged?
Comment 5 SpanKY gentoo-dev 2008-04-16 18:40:25 UTC
i'll merge it as soon as you test it and say it works for you
Comment 6 d_m 2008-04-16 18:55:25 UTC
Ok, yeah it seems great.

With the environment variable unset, things work as normal. With it set, I am able to turn off highlighting for particular extensions.

Interestingly, it doesn't seem to have to be colon-seperated. For instance, the following two invocations seem to work equally well:

LESSIGNORE="mp3 html" less foo.mp3
LESSIGNORE="mp3:html" less foo.mp3

Also, compound extensions (e.g. tar.gz or 1.bz2) seem to work.

It looks good. Thanks for helping me with this!
Comment 7 SpanKY gentoo-dev 2008-04-18 19:58:06 UTC
thanks for testing ... ive added the code in question (minus the colon filter, so now it's just a space delimited list)

http://sources.gentoo.org/sys-apps/less/files/lesspipe.sh?r1=1.28&r2=1.29