shithub: figlet

ref: d34ddd8775ca8ebad64222911e5dd60069918b54
dir: /figlist/

View raw version
#!/bin/rc
# figlist by Glenn Chappell <ggc@uiuc.edu>
# figlet release 2.1.1 -- 25 Aug 1994
#
# adapted for Rc by Lee Duhem <lee.duhem@gmail.com>
# February 2007
#
# Lists all fonts and control files in figlet's default font directory.
# Replaces "figlet -F", which was removed from figlet version 2.1.
#
# Usage: figlist [ -d directory ]

# Set up $path so figlet can be found
path=(. /bin /bin/games /bin/games/figlet)

# Get figlet version
FIGLETVERSION=`{figlet -I1 >[2]/dev/null}
if (test -z "$FIGLETVERSION" )
  FIGLETVERSION=20000

USAGE='Usage: '^ `{basename $0} ^' [ -d directory ]'

if(~ $1 -d){
  FONTDIROPT=(-d $2)
  if(! ~ $#* 2){
    echo $USAGE
    exit usage
  }
}
if not {
  FONTDIROPT=''
  if(! ~ $#* 0){
    echo $USAGE
    exit usage
  }
}

if(test $FIGLETVERSION -lt 20100){
  # figlet 2.0
  figlet $FONTDIROPT -F
  exit
}

# From here on we may assume figlet 2.1 or later

FONTDIR=`{eval figlet $FONTDIROPT -I2}
FONT=`{figlet -I3}
echo Default font: $FONT
echo Font directory: $FONTDIR

if (test (-d $FONTDIR) -a (-r $FONTDIR)){
  cd $FONTDIR
  if(ls *.flf >/dev/null >[2=1]){
    echo 'Figlet fonts in this directory:'
    ls *.flf >[2] /dev/null | sed 's/\.flf$//'
  }
  if not
    echo 'No figlet fonts in this directory'

  if(ls *.flc >/dev/null >[2=1]){
    echo 'Figlet control files in this directory:'
    ls *.flc >[2] /dev/null | sed 's/\.flc$//'
  }
  if not
    echo 'No figlet control files in this directory'
}
if not
  echo 'Unable to open directory'