about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2023-01-06 22:03:57 -0600
committerCase Duckworth2023-01-06 22:03:57 -0600
commitcb9fa2a4ccf7154f473d50c42e0869efd65d7b9d (patch)
tree8e92c7c144e87bc41c5c9a7dac5cfc4faed6f7f9
parentProperly log configuration variables (diff)
downloadvienna-cb9fa2a4ccf7154f473d50c42e0869efd65d7b9d.tar.gz
vienna-cb9fa2a4ccf7154f473d50c42e0869efd65d7b9d.zip
Change gencheckglob calling convention
-rwxr-xr-xvienna35
1 files changed, 21 insertions, 14 deletions
diff --git a/vienna b/vienna index f8d2d31..6af1eb4 100755 --- a/vienna +++ b/vienna
@@ -107,15 +107,17 @@ main() {
107 log config "output: $OUTD" 107 log config "output: $OUTD"
108 ## Plugins 108 ## Plugins
109 # Plugins are .*.sh files in build directory. They're sourced here. 109 # Plugins are .*.sh files in build directory. They're sourced here.
110 for plugin in ./.*.sh; do 110 if gencheckglob './.*.sh' ./.*.sh; then
111 case "$plugin" in 111 for plugin in ./.*.sh; do
112 *"$CONFIG"*) continue ;; 112 case "$plugin" in
113 *) 113 *"$CONFIG"*) continue ;;
114 log plugin "source $plugin" 114 *)
115 . "$plugin" 115 log plugin "$plugin"
116 ;; 116 . "$plugin"
117 esac 117 ;;
118 done 118 esac
119 done
120 fi
119 mkdir -p "$OUTD" || exit 2 121 mkdir -p "$OUTD" || exit 2
120 mkdir -p "$TMPD" || exit 2 122 mkdir -p "$TMPD" || exit 2
121 # Build pages 123 # Build pages
@@ -277,17 +279,18 @@ filters() { # filters < INPUT
277 279
278### Site building 280### Site building
279 281
280gencheckglob() { # gencheckglob PAGE... 282gencheckglob() { # gencheckglob GLOBPATTERN PAGE...
281 ## Sanity check for PAGE(s) in generating functions. 283 ## Sanity check for PAGE(s) in generating functions.
282 # When globbing is on, if no files matching the pattern exist then the shell 284 # When globbing is on, if no files matching the pattern exist then the shell
283 # thinks I want to work on a file named the literal glob. Ugh. This 285 # thinks I want to work on a file named the literal glob. Ugh. This
284 # function checks for that weirdness. 286 # function checks for that weirdness.
285 # 287 #
286 # Returns success if there's more than one argument (i.e., the glob worked), 288 # Returns success if there's more than one argument (i.e., the glob worked),
287 # or failure if there's one argument of the pattern *.$PAGE_RAW_EXT. 289 # or failure if there's one argument of the pattern GLOBPATTERN.
290 globpattern="$1"; shift
288 if [ $# -gt 1 ]; then 291 if [ $# -gt 1 ]; then
289 return 0 292 return 0
290 elif [ "$1" = "*.$PAGE_RAW_EXT" ]; then 293 elif [ "$1" = "$globpattern" ]; then
291 return 1 294 return 1
292 else 295 else
293 return 0 296 return 0
@@ -298,7 +301,7 @@ genpage() { # genpage PAGE...
298 ## Compile PAGE(s) into $OUTD for publication. 301 ## Compile PAGE(s) into $OUTD for publication.
299 # Outputs a file of the format $OUTD/<PAGE>/index.html. 302 # Outputs a file of the format $OUTD/<PAGE>/index.html.
300 test -f "$PAGE_TEMPLATE" || return 1 303 test -f "$PAGE_TEMPLATE" || return 1
301 gencheckglob "$@" || set -- 304 gencheckglob "*.$PAGE_RAW_EXT" "$@" || set --
302 for FILE; do 305 for FILE; do
303 log genpage "$FILE" 306 log genpage "$FILE"
304 outd="$OUTD/${FILE%.$PAGE_RAW_EXT}" 307 outd="$OUTD/${FILE%.$PAGE_RAW_EXT}"
@@ -316,7 +319,10 @@ genlist() { # genlist PERITEM_FUNC TEMPLATE_FILE PAGE...
316 tmpf="$TMPD/$1" 319 tmpf="$TMPD/$1"
317 shift 2 || return 2 320 shift 2 || return 2
318 test -f "$template_file" || return 1 321 test -f "$template_file" || return 1
319 gencheckglob "$@" || { echo | expand "$template_file"; return; } 322 if ! gencheckglob "*.$PAGE_RAW_EXT" "$@"; then
323 echo | expand "$template_file"
324 return
325 fi
320 for FILE; do 326 for FILE; do
321 log genlist "$peritem_func: $template_file: $FILE" 327 log genlist "$peritem_func: $template_file: $FILE"
322 LINK="$DOMAIN${DOMAIN:+/}${FILE%.$PAGE_RAW_EXT}" 328 LINK="$DOMAIN${DOMAIN:+/}${FILE%.$PAGE_RAW_EXT}"
@@ -344,6 +350,7 @@ static() { # static FILE...
344 ## Copy static FILE(s) to $OUTD as-is. 350 ## Copy static FILE(s) to $OUTD as-is.
345 # Performs a simple heuristic to determine whether to copy a file or 351 # Performs a simple heuristic to determine whether to copy a file or
346 # not. 352 # not.
353 gencheckglob "*" "$@" || return
347 for FILE; do 354 for FILE; do
348 case "$FILE" in 355 case "$FILE" in
349 .*) continue ;; 356 .*) continue ;;