From cb9fa2a4ccf7154f473d50c42e0869efd65d7b9d Mon Sep 17 00:00:00 2001
From: Case Duckworth
Date: Fri, 6 Jan 2023 22:03:57 -0600
Subject: Change gencheckglob calling convention

---
 vienna | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/vienna b/vienna
index f8d2d31..6af1eb4 100755
--- a/vienna
+++ b/vienna
@@ -107,15 +107,17 @@ main() {
     log config "output: $OUTD"
     ## Plugins
     # Plugins are .*.sh files in build directory.  They're sourced here.
-    for plugin in ./.*.sh; do
-	case "$plugin" in
-	    *"$CONFIG"*) continue ;;
-	    *)
-		log plugin "source $plugin"
-		. "$plugin"
-		;;
-	esac
-    done
+    if gencheckglob './.*.sh' ./.*.sh; then
+	for plugin in ./.*.sh; do
+	    case "$plugin" in
+		*"$CONFIG"*) continue ;;
+		*)
+		    log plugin "$plugin"
+		    . "$plugin"
+		    ;;
+	    esac
+	done
+    fi
     mkdir -p "$OUTD" || exit 2
     mkdir -p "$TMPD" || exit 2
     # Build pages
@@ -277,17 +279,18 @@ filters() { # filters < INPUT
 
 ### Site building
 
-gencheckglob() { # gencheckglob PAGE...
+gencheckglob() { # gencheckglob GLOBPATTERN PAGE...
     ## Sanity check for PAGE(s)	in generating functions.
     # When globbing is on, if no files matching the pattern exist then the shell
     # thinks I want to work on a file named the literal glob.  Ugh.  This
     # function checks for that weirdness.
     #
     # Returns success if there's more than one argument (i.e., the glob worked),
-    # or failure if there's one argument of the pattern *.$PAGE_RAW_EXT.
+    # or failure if there's one argument of the pattern GLOBPATTERN.
+    globpattern="$1"; shift
     if [ $# -gt 1 ]; then
 	return 0
-    elif [ "$1" = "*.$PAGE_RAW_EXT" ]; then
+    elif [ "$1" = "$globpattern" ]; then
 	return 1
     else
 	return 0
@@ -298,7 +301,7 @@ genpage() { # genpage PAGE...
     ## Compile PAGE(s) into $OUTD for publication.
     # Outputs a file of the format $OUTD/<PAGE>/index.html.
     test -f "$PAGE_TEMPLATE" || return 1
-    gencheckglob "$@" || set --
+    gencheckglob "*.$PAGE_RAW_EXT" "$@" || set --
     for FILE; do
         log genpage "$FILE"
         outd="$OUTD/${FILE%.$PAGE_RAW_EXT}"
@@ -316,7 +319,10 @@ genlist() { # genlist PERITEM_FUNC TEMPLATE_FILE PAGE...
     tmpf="$TMPD/$1"
     shift 2 || return 2
     test -f "$template_file" || return 1
-    gencheckglob "$@" || { echo | expand "$template_file"; return; }
+    if ! gencheckglob "*.$PAGE_RAW_EXT" "$@"; then
+	echo | expand "$template_file"
+	return
+    fi
     for FILE; do
         log genlist "$peritem_func: $template_file: $FILE"
         LINK="$DOMAIN${DOMAIN:+/}${FILE%.$PAGE_RAW_EXT}"
@@ -344,6 +350,7 @@ static() { # static FILE...
     ## Copy static FILE(s) to $OUTD as-is.
     # Performs a simple heuristic to determine whether to copy a file or
     # not.
+    gencheckglob "*" "$@" || return
     for FILE; do
         case "$FILE" in
             .*) continue ;;
-- 
cgit 1.4.1-21-gabe81