From c2398c50ee5e2b06f9e9d80a7419bb50b8626c1b Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 7 Jan 2023 20:33:22 -0600 Subject: Remove gencheckglob Some well-positioned `test -f`s do just as well. --- vienna | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/vienna b/vienna index c969948..7a7818d 100755 --- a/vienna +++ b/vienna @@ -374,30 +374,12 @@ filters() { # filters < INPUT ### Site building -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 GLOBPATTERN. - globpattern="$1"; shift - if [ $# -gt 1 ]; then - return 0 - elif [ "$1" = "$globpattern" ]; then - return 1 - else - return 0 - fi -} - 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 "*.$PAGE_RAW_EXT" "$@" || set -- for FILE; do + test -f "$FILE" || continue log genpage "$FILE" outd="$OUTD/${FILE%.$PAGE_RAW_EXT}" outf="$outd/index.html" @@ -417,12 +399,9 @@ genlist() { # genlist PERITEM_FUNC TEMPLATE_FILE PAGE... tmpf="$TMPD/$1" shift 2 || return 2 test -f "$template_file" || return 1 - if ! gencheckglob "*.$PAGE_RAW_EXT" "$@"; then - echo | expand "$template_file" - return - fi printf '%s\n' "$@" | sort_items | while read -r FILE; do + test -f "$FILE" || continue log genlist "$peritem_func" "$FILE" LINK="$DOMAIN${DOMAIN:+/}${FILE%.$PAGE_RAW_EXT}" META="$TMPD/$FILE.meta" @@ -456,8 +435,8 @@ 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 + test -f "$FILE" || continue case "$FILE" in .*) continue ;; *.htm) continue ;; -- cgit 1.4.1-21-gabe81