From df64f6c7d2a7121a6475ce653a1e2c5708ea589d Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 2 Jan 2023 00:33:06 -0600 Subject: Add gencheckglob() --- vienna | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vienna b/vienna index 1a52a7d..3d6a4a3 100755 --- a/vienna +++ b/vienna @@ -266,10 +266,23 @@ filters() { # filters < INPUT ### Site building +gencheckglob() { # gencheckglob 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. + [ $# -gt 1 ] && return 0 + [ "$1" = "*.$PAGE_RAW_EXT" ] && return 1 +} + genpage() { # genpage PAGE... ## Compile PAGE(s) into $OUTD for publication. # Outputs a file of the format $OUTD//index.html. test -f "$PAGE_TEMPLATE" || return 1 + gencheckglob "$@" || set -- for FILE; do log genpage "$FILE" outd="$OUTD/${FILE%.$PAGE_RAW_EXT}" @@ -287,6 +300,7 @@ 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; } for FILE; do log genlist "$peritem_func: $template_file: $FILE" LINK="$DOMAIN${DOMAIN:+/}${FILE%.$PAGE_RAW_EXT}" -- cgit 1.4.1-21-gabe81