about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2023-01-07 20:33:22 -0600
committerCase Duckworth2023-01-07 20:33:22 -0600
commitc2398c50ee5e2b06f9e9d80a7419bb50b8626c1b (patch)
tree4b7fd77929c56bc146c34c5129bc88b0e1ebc8ca
parentAdd `init' command (diff)
downloadvienna-c2398c50ee5e2b06f9e9d80a7419bb50b8626c1b.tar.gz
vienna-c2398c50ee5e2b06f9e9d80a7419bb50b8626c1b.zip
Remove gencheckglob
Some well-positioned `test -f`s	do just as well.
-rwxr-xr-xvienna27
1 files 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
374 374
375### Site building 375### Site building
376 376
377gencheckglob() { # gencheckglob GLOBPATTERN PAGE...
378 ## Sanity check for PAGE(s) in generating functions.
379 # When globbing is on, if no files matching the pattern exist then the shell
380 # thinks I want to work on a file named the literal glob. Ugh. This
381 # function checks for that weirdness.
382 #
383 # Returns success if there's more than one argument (i.e., the glob worked),
384 # or failure if there's one argument of the pattern GLOBPATTERN.
385 globpattern="$1"; shift
386 if [ $# -gt 1 ]; then
387 return 0
388 elif [ "$1" = "$globpattern" ]; then
389 return 1
390 else
391 return 0
392 fi
393}
394
395genpage() { # genpage PAGE... 377genpage() { # genpage PAGE...
396 ## Compile PAGE(s) into $OUTD for publication. 378 ## Compile PAGE(s) into $OUTD for publication.
397 # Outputs a file of the format $OUTD/<PAGE>/index.html. 379 # Outputs a file of the format $OUTD/<PAGE>/index.html.
398 test -f "$PAGE_TEMPLATE" || return 1 380 test -f "$PAGE_TEMPLATE" || return 1
399 gencheckglob "*.$PAGE_RAW_EXT" "$@" || set --
400 for FILE; do 381 for FILE; do
382 test -f "$FILE" || continue
401 log genpage "$FILE" 383 log genpage "$FILE"
402 outd="$OUTD/${FILE%.$PAGE_RAW_EXT}" 384 outd="$OUTD/${FILE%.$PAGE_RAW_EXT}"
403 outf="$outd/index.html" 385 outf="$outd/index.html"
@@ -417,12 +399,9 @@ genlist() { # genlist PERITEM_FUNC TEMPLATE_FILE PAGE...
417 tmpf="$TMPD/$1" 399 tmpf="$TMPD/$1"
418 shift 2 || return 2 400 shift 2 || return 2
419 test -f "$template_file" || return 1 401 test -f "$template_file" || return 1
420 if ! gencheckglob "*.$PAGE_RAW_EXT" "$@"; then
421 echo | expand "$template_file"
422 return
423 fi
424 printf '%s\n' "$@" | sort_items | 402 printf '%s\n' "$@" | sort_items |
425 while read -r FILE; do 403 while read -r FILE; do
404 test -f "$FILE" || continue
426 log genlist "$peritem_func" "$FILE" 405 log genlist "$peritem_func" "$FILE"
427 LINK="$DOMAIN${DOMAIN:+/}${FILE%.$PAGE_RAW_EXT}" 406 LINK="$DOMAIN${DOMAIN:+/}${FILE%.$PAGE_RAW_EXT}"
428 META="$TMPD/$FILE.meta" 407 META="$TMPD/$FILE.meta"
@@ -456,8 +435,8 @@ static() { # static FILE...
456 ## Copy static FILE(s) to $OUTD as-is. 435 ## Copy static FILE(s) to $OUTD as-is.
457 # Performs a simple heuristic to determine whether to copy a file or 436 # Performs a simple heuristic to determine whether to copy a file or
458 # not. 437 # not.
459 gencheckglob "*" "$@" || return
460 for FILE; do 438 for FILE; do
439 test -f "$FILE" || continue
461 case "$FILE" in 440 case "$FILE" in
462 .*) continue ;; 441 .*) continue ;;
463 *.htm) continue ;; 442 *.htm) continue ;;