#!/bin/sh

# This is a preprocessor for 'less'.  It is used when this environment
# variable is set:   LESSOPEN="|lessopen %s"

PATH=/usr/gnu/bin:$PATH

case "$1" in *\|) exec perl -pe 1 "$1";; esac

test -r "$1" || exec ls -Lla "$1"
test -d "$1" && exec ls -Lla "$1"

case "$1" in
  /proc/*) exec tr \\0 \\012 < "$1";;
  *consolefonts/?*) exec perl -0pe 's/./unpack("B*",$&)."\n"/ge&&y/01/-#/' "$1";;
  *.bdf) exec perl -pe '
	s/^([0-9A-F]+)$/unpack("B*",pack("H*",$1))/gei&&y/01/-#/' "$1";;
  *.bdf.gz) exec perl -pe '
	s/^([0-9A-F]+)$/unpack("B*",pack("H*",$1))/gei&&y/01/-#/' "zcat $1|";;
  *.dvi) exec dvi2tty -q "$1";;
  *.tar) exec tar tvvf "$1";;
  *.tgz|*.tar.gz|*.tar.Z) exec tar tvvfz "$1";;
  *man[1-9]*/*.gz) gzip -dc "$1" | nroff -man;;
  *.gz|*.[Zz]) exec gzip -dc "$1";;
  *.zip) exec unzip -l "$1";;
  *.fon) od -t x1 "$1"; strings "$1";;
  *.o|*.a|*lib*.so|*lib*.so.[1-9]*) file "$1"; exec nm -ACgs "$1";;
  *.[1-9n]|*.man) exec nroff -man "$1";;
esac

if test -x "$1" && size "$1" >/dev/null 2>&1
then file -L "$1"; echo; size "$1"; echo; ldd "$1"; echo; exec strings - "$1"
fi

# $Id: lessopen,v 1.19 1998/05/13 17:09:51 czyborra Exp $
