diff --git a/scripts/man.sh b/scripts/man.sh new file mode 100755 index 0000000000000000000000000000000000000000..94b311ccb4aa5eeea5e64bfb2bbaed250cee779e --- /dev/null +++ b/scripts/man.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +# $0: script name +# $1: input +# $2: output +[ $# -ne 2 ] && exit 1 +[ "$1" == "$2" ] && exit 2 + +# Global variables +HEADER="doc/header" +FOOTER="doc/footer" + +# Functions +function the_day() { + # $1: file + # $2: what to replace with the date + local DATE=$(date +'%B %d, %Y') + sed -i "s/$2/$DATE/g" "$1" +} + +function the_page() { + # $1: file + # $2: what to replace with the date + FILE=$(basename "$1") + FILE="${FILE%.*}" + FILE="${FILE^^}" + sed -i "s/$2/$FILE/g" "$1" +} + +function mk_manpage() { + # $1: input + # $2: output + cat $HEADER > $2 + cat $1 >> $2 + cat $FOOTER >> $2 + the_day "$2" '___DATE___' + the_page "$2" '___PAGE___' +} + +mk_manpage "$1" "$2" +exit 0