chiark / gitweb /
19630dc672a30e7528cce81a1d1347f11b9d5c0b
[bin.git] / get-sig
1 #! /bin/sh
2
3 if [ -z "$1" ]; then
4   NAME=$(grep '^\*' ~/.siglist | head -n 1 | tr -s '\t' ' ' | cut -d' ' -f2)
5   if [ -z "$NAME" ]; then
6     echo "Usage: $0 signature-group [pattern]" >&2
7     exit 1
8   fi
9 else
10   NAME=$1
11 fi
12
13 ARGS=$(grep "^$NAME\\>" ~/.siglist | head -n 1 | tr -s '\t' ' ' | cut -d' ' -f2-)
14 if [ -z "$ARGS" ]; then
15     echo "No such signature group: $NAME" >&2
16     exit 1
17 fi
18
19 BASEDIR=$(eval echo $(echo "$ARGS" | cut -d' ' -f1))
20 STATICFILE=$(eval echo $(echo "$ARGS" | cut -d' ' -f2))
21 FORTUNEARGS=$(eval echo $(echo "$ARGS" | cut -d' ' -f3-))
22
23 cd "$HOME/$BASEDIR"
24 cat "$STATICFILE"
25 if [ "$2" ]; then fortune $FORTUNEARGS -m "$2"; else fortune $FORTUNEARGS; fi