about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2023-01-02 00:33:06 -0600
committerCase Duckworth2023-01-02 00:33:06 -0600
commitdf64f6c7d2a7121a6475ce653a1e2c5708ea589d (patch)
tree25e1f1e7b7dc529332703ecdd1bc7d3dbd6f449a
parentFix bug with linking (diff)
downloadvienna-df64f6c7d2a7121a6475ce653a1e2c5708ea589d.tar.gz
vienna-df64f6c7d2a7121a6475ce653a1e2c5708ea589d.zip
Add gencheckglob()
-rwxr-xr-xvienna14
1 files changed, 14 insertions, 0 deletions
diff --git a/vienna b/vienna index 1a52a7d..3d6a4a3 100755 --- a/vienna +++ b/vienna
@@ -266,10 +266,23 @@ filters() { # filters < INPUT
266 266
267### Site building 267### Site building
268 268
269gencheckglob() { # gencheckglob PAGE...
270 ## Sanity check for PAGE(s) in generating functions.
271 # When globbing is on, if no files matching the pattern exist then the shell
272 # thinks I want to work on a file named the literal glob. Ugh. This
273 # function checks for that weirdness.
274 #
275 # Returns success if there's more than one argument (i.e., the glob worked),
276 # or failure if there's one argument of the pattern *.$PAGE_RAW_EXT.
277 [ $# -gt 1 ] && return 0
278 [ "$1" = "*.$PAGE_RAW_EXT" ] && return 1
279}
280
269genpage() { # genpage PAGE... 281genpage() { # genpage PAGE...
270 ## Compile PAGE(s) into $OUTD for publication. 282 ## Compile PAGE(s) into $OUTD for publication.
271 # Outputs a file of the format $OUTD/<PAGE>/index.html. 283 # Outputs a file of the format $OUTD/<PAGE>/index.html.
272 test -f "$PAGE_TEMPLATE" || return 1 284 test -f "$PAGE_TEMPLATE" || return 1
285 gencheckglob "$@" || set --
273 for FILE; do 286 for FILE; do
274 log genpage "$FILE" 287 log genpage "$FILE"
275 outd="$OUTD/${FILE%.$PAGE_RAW_EXT}" 288 outd="$OUTD/${FILE%.$PAGE_RAW_EXT}"
@@ -287,6 +300,7 @@ genlist() { # genlist PERITEM_FUNC TEMPLATE_FILE PAGE...
287 tmpf="$TMPD/$1" 300 tmpf="$TMPD/$1"
288 shift 2 || return 2 301 shift 2 || return 2
289 test -f "$template_file" || return 1 302 test -f "$template_file" || return 1
303 gencheckglob "$@" || { echo | expand "$template_file"; return; }
290 for FILE; do 304 for FILE; do
291 log genlist "$peritem_func: $template_file: $FILE" 305 log genlist "$peritem_func: $template_file: $FILE"
292 LINK="$DOMAIN${DOMAIN:+/}${FILE%.$PAGE_RAW_EXT}" 306 LINK="$DOMAIN${DOMAIN:+/}${FILE%.$PAGE_RAW_EXT}"