shithub: figlet

ref: 1adf41744cbbdfdb7c834c92bd37280650fb7b5a
dir: /figlist/

View raw version
#!/bin/rc
# figlist by Glenn Chappell <[email protected]>
# figlet release 2.1.1 -- 25 Aug 1994
#
# adapted for Rc by Lee Duhem <[email protected]>
# 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/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'