packages: lesspipe/lesspipe.sh - check if less would parse escape sequences...

gotar gotar at pld-linux.org
Thu May 28 12:51:43 CEST 2009


Author: gotar                        Date: Thu May 28 10:51:43 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- check if less would parse escape sequences as colors, either by
  LESS environment variable having -?[rR] (note: doesn't have to be separate
	word, there might be false positive test results), or
  less itself having -[rR] switch (note2: only before first non-option
	argument, so some false positives possible too)
  Skip highlight(ing) when it wouldn't interpret them.

---- Files affected:
packages/lesspipe:
   lesspipe.sh (1.38 -> 1.39) 

---- Diffs:

================================================================
Index: packages/lesspipe/lesspipe.sh
diff -u packages/lesspipe/lesspipe.sh:1.38 packages/lesspipe/lesspipe.sh:1.39
--- packages/lesspipe/lesspipe.sh:1.38	Thu May 28 11:23:47 2009
+++ packages/lesspipe/lesspipe.sh	Thu May 28 12:51:38 2009
@@ -82,7 +82,8 @@
 		xterm|xterm-color)	output=xterm256;;
 		*)			output=ansi;;
 	   esac
-		run-mailcap "$1" || highlight --$output --style=darkblue "$1"
+		run-mailcap "$1" || \
+		{ echo $LESS | grep -qi r || ps -p `ps -p $PPID -oppid=` -oargs= | grep -qiw -- -r && highlight --$output --style=darkblue "$1"; }
    	# Check to see if binary, if so -- view with 'strings'
    	# FILE=$(file -L "$1")
 	esac
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/lesspipe/lesspipe.sh?r1=1.38&r2=1.39&f=u



More information about the pld-cvs-commit mailing list