From ee71daad96a70fad8ac7dae87a17d51900e527a2 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 20 Jan 2011 03:26:14 +0000 Subject: allow files matching a `file` string to fall back to colorization if there are no shell script matches #351426 by Raphaƫl Vinot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (Portage version: 2.2.0_alpha13/cvs/Linux x86_64) --- sys-apps/less/files/lesspipe.sh | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'sys-apps/less/files/lesspipe.sh') diff --git a/sys-apps/less/files/lesspipe.sh b/sys-apps/less/files/lesspipe.sh index 8bbf67678262..b656e3067f2e 100644 --- a/sys-apps/less/files/lesspipe.sh +++ b/sys-apps/less/files/lesspipe.sh @@ -188,19 +188,13 @@ lesspipe() { ### Everything else ### *) - # Sanity check - [[ ${recur} == 2 ]] && exit 0 + case $(( recur++ )) in + # Maybe we didn't match due to case issues ... + 0) lesspipe "$1" "$(echo $1 | LC_ALL=C tr '[:upper:]' '[:lower:]')" ;; - # Maybe we didn't match due to case issues ... - if [[ ${recur} == 0 ]] ; then - recur=1 - lesspipe "$1" "$(echo $1 | LC_ALL=C tr '[:upper:]' '[:lower:]')" - - # Maybe we didn't match because the file is named weird ... - else - recur=2 - lesspipe_file "$1" - fi + # Maybe we didn't match because the file is named weird ... + 1) lesspipe_file "$1" ;; + esac # So no matches from above ... finally fall back to an external # coloring package. No matching here so we don't have to worry @@ -235,7 +229,7 @@ if [[ -z $1 ]] ; then elif [[ $1 == "-V" || $1 == "--version" ]] ; then Id="cvsid" cat <<-EOF - $Id: lesspipe.sh,v 1.44 2011/01/18 20:26:13 vapier Exp $ + $Id: lesspipe.sh,v 1.45 2011/01/20 03:26:14 vapier Exp $ Copyright 2001-2010 Gentoo Foundation Mike Frysinger (with plenty of ideas stolen from other projects/distros) -- cgit v1.2.3-65-gdbad