diff options
author | jwinnie <jwinnie@tilde.institute> | 2021-11-30 11:14:56 -0800 |
---|---|---|
committer | jwinnie <jwinnie@tilde.institute> | 2021-11-30 11:14:56 -0800 |
commit | 6a480e6bddbbc91e288063e511dfcf6c7d463e63 (patch) | |
tree | bce4d055575824e8cfc1911b57ad5e83ca0beb78 | |
parent | 94096519799fb245e3291869d1e1d199fa948338 (diff) | |
download | gmi2html-6a480e6bddbbc91e288063e511dfcf6c7d463e63.tar.gz |
Improve gmi2htmldir.sh documentation, fix a few bugs
-rwxr-xr-x | gmi2htmldir.sh | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/gmi2htmldir.sh b/gmi2htmldir.sh index 42babfb..67b8c3c 100755 --- a/gmi2htmldir.sh +++ b/gmi2htmldir.sh @@ -32,11 +32,25 @@ title=$3 css=$4 url=$5 -gmi2html=${PWD}/$(dirname $0)/gmi2html.awk +# Get the path of the gmi2html.awk script, which is in the +# same directory as this one. +# +# Credit to T.J. Crowder from Stack Overflow for the method +# of finding $SCRIPTPATH: https://stackoverflow.com/a/4774063 +SCRIPTPATH=$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P) +gmi2html=${SCRIPTPATH}/gmi2html.awk +# Loop through all the files in the directory (cd to the directory +# so that we get the relative path with relation to the root directory +# of each file) cd $in for f in *.gmi **/*.gmi; do + # Replace .gmi extension with .html HTML_FILENAME=$out/${f%.gmi}.html echo "processing: ${f} -> ${HTML_FILENAME}" - awk -f $gmi2html -v $title -v $css -v $url < $f > $HTML_FILENAME + + # Run the gmi2html.awk script, passing in the parameters + awk -f $gmi2html -v $title -v $css -v $url \ + < $f \ + > $HTML_FILENAME done |