summary refs log tree commit diff stats
path: root/gmi2htmldir.sh
diff options
context:
space:
mode:
Diffstat (limited to 'gmi2htmldir.sh')
-rwxr-xr-xgmi2htmldir.sh18
1 files changed, 16 insertions, 2 deletions
diff --git a/gmi2htmldir.sh b/gmi2htmldir.sh
index 2a20673..6359dd0 100755
--- a/gmi2htmldir.sh
+++ b/gmi2htmldir.sh
@@ -32,11 +32,25 @@ title=$3
 css=$4
 original=$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 $original < $f > $HTML_FILENAME
+
+  # Run the gmi2html.awk script, passing in the parameters
+  awk -f $gmi2html -v $title -v $css -v $original \
+    < $f \
+    > $HTML_FILENAME
 done