sys-apps/less: lesspipe: handle all non-regular files in main code
authorMike Frysinger <vapier@gentoo.org>
Wed, 6 Apr 2016 21:45:29 +0000 (17:45 -0400)
committerMike Frysinger <vapier@gentoo.org>
Wed, 6 Apr 2016 22:09:25 +0000 (18:09 -0400)
sys-apps/less/files/lesspipe.sh

index d659e39e1374945e1be61aa71bc7a84233d979c7..c0f30e3073044fca54e49fb7decb41b8eb612765 100755 (executable)
@@ -59,6 +59,15 @@ lesspipe() {
                [[ ${match} == *.${ignore} ]] && exit 0
        done
 
+       # Handle non-regular file types.
+       if [[ -d $1 ]] ; then
+               ls -alF -- "$1"
+               return
+       elif [[ ! -f $1 ]] ; then
+               stat "$1"
+               return
+       fi
+
        case "${match}" in
 
        ### Doc files ###
@@ -234,14 +243,12 @@ lesspipe() {
 if [[ -z $1 ]] ; then
        echo "Usage: lesspipe <file>"
 elif [[ $1 == "-V" || $1 == "--version" ]] ; then
-       Id="cvsid"
        cat <<-EOF
-               $Id$
-               Copyright 2001-2013 Gentoo Foundation
+               lesspipe (git)
+               Copyright 2001-2016 Gentoo Foundation
                Mike Frysinger <vapier@gentoo.org>
                     (with plenty of ideas stolen from other projects/distros)
 
-
        EOF
        less -V
 elif [[ $1 == "-h" || $1 == "--help" ]] ; then
@@ -265,8 +272,6 @@ elif [[ $1 == "-h" || $1 == "--help" ]] ; then
 
                Run 'less --help' or 'man less' for more info.
        EOF
-elif [[ -d $1 ]] ; then
-       ls -alF -- "$1"
 else
        recur=0
        [[ -n ${LESSDEBUG} ]] \