aboutsummaryrefslogtreecommitdiffstats
path: root/figlist
blob: 3f629f4cee1a76c8239c0cd05a72929f8b85840c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh -
# figlist by Glenn Chappell <ggc@uiuc.edu>
# figlet release 2.1.1 -- 25 Aug 1994
#
# 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
DIRSAVE=`pwd`
cd `dirname "$0"`
PATH="$PATH":`pwd`
cd "$DIRSAVE"

# Get figlet version
FIGLETVERSION=`figlet -I1 2>/dev/null`
if [ -z "$FIGLETVERSION" ]; then
  FIGLETVERSION=20000
fi

USAGE="Usage: `basename $0` [ -d directory ]"

if [ "$1" = "-d" ]; then
  FONTDIROPT="-d $2"
  if [ $# -ne 2 ]; then
    echo "$USAGE"
    exit 1
  fi
else
  FONTDIROPT=""
  if [ $# -ne 0 ]; then
    echo "$USAGE"
    exit 1
  fi
fi

if [ "$FIGLETVERSION" -lt 20100 ]; then
  # figlet 2.0
  figlet $FONTDIROPT -F
  exit
fi

# From here on we may assume figlet 2.1 or later

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

if [ -d "$FONTDIR" ] && [ -r "$FONTDIR" ]; then
  cd "$FONTDIR"
  if ls *.flf >/dev/null 2>&1 ; then
    echo "Figlet fonts in this directory:"
    ls *.flf 2>/dev/null | sed s/\.flf$//
  else
    echo 'No figlet fonts in this directory'
  fi
  if ls *.flc >/dev/null 2>&1 ; then
    echo "Figlet control files in this directory:"
    ls *.flc 2>/dev/null | sed s/\.flc$//
  else
    echo 'No figlet control files in this directory'
  fi
else
  echo 'Unable to open directory'
fi