aboutsummaryrefslogtreecommitdiff
path: root/format.sh
blob: a268ef5ae63e8429041911f5cf2ae92e414ecc1a (plain) (blame)
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
#!/bin/sh
##
# Usage: format.sh TEMPLATE
#
# This runs recfmt w/ template file TEMPLATE on stdin, writing to stdout.
##
me=$(basename $0)

version='1.2'
# 1.2  -- add check for required arg TEMPLATE
# 1.1  -- add --help/--version support
# 1.0  -- initial release

if [ x"$1" = x--help ] ; then
    sed '/^##/,/^##/!d;/^##/d;s/^# //g;s/^#$//g' $0
    exit 0
fi

if [ x"$1" = x--version ] ; then
    echo $me '(gana)' $version
    exit 0
fi

if [ x"$1" = x ] ; then
    echo >&2 "$me: ERROR: missing arg TEMPLATE (try --help)"
    exit 1
fi

template="$1"

exec recfmt -f "$template"

# format.sh ends here