aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThien-Thi Nguyen <ttn@gnuvola.org>2022-04-24 09:17:30 -0400
committerThien-Thi Nguyen <ttn@gnuvola.org>2022-04-24 09:17:30 -0400
commitf99c5dd2c488f132024b38aa71b0be18ab4b6fd3 (patch)
treef0acc8855a0a4c9ce609324c57f96dee25236524
parentbffe32411e8ded537c5615ea054b43b3f7334bcd (diff)
downloadgana-f99c5dd2c488f132024b38aa71b0be18ab4b6fd3.tar.gz
gana-f99c5dd2c488f132024b38aa71b0be18ab4b6fd3.zip
add --help/--version support
* format.sh (me, version): New vars. <top-level>: Handle ‘--help’ on command line. <top-level>: Likewise for ‘--version’. (template): New var. <top-level>: Use ‘recfmt -f’ and ‘$template’.
-rwxr-xr-xformat.sh27
1 files changed, 26 insertions, 1 deletions
diff --git a/format.sh b/format.sh
index 9af69f1..f48dda6 100755
--- a/format.sh
+++ b/format.sh
@@ -1,2 +1,27 @@
1#!/bin/sh 1#!/bin/sh
2exec recfmt "`cat $1`" 2##
3# Usage: format.sh TEMPLATE
4#
5# This runs recfmt w/ template file TEMPLATE on stdin, writing to stdout.
6##
7me=$(basename $0)
8
9version='1.1'
10# 1.1 -- add --help/--version support
11# 1.0 -- initial release
12
13if [ x"$1" = x--help ] ; then
14 sed '/^##/,/^##/!d;/^##/d;s/^# //g;s/^#$//g' $0
15 exit 0
16fi
17
18if [ x"$1" = x--version ] ; then
19 echo $me '(gana)' $version
20 exit 0
21fi
22
23template="$1"
24
25exec recfmt -f "$template"
26
27# format.sh ends here