From 0d29cc71734dbc96e0e76ccdaa640aba957f3ec8 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 9 Apr 2025 17:10:45 -0300 Subject: src/conf: Extract embedded-config from document header variables --- src/conf | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/conf b/src/conf index fa753e9..b423e23 100755 --- a/src/conf +++ b/src/conf @@ -92,13 +92,14 @@ eval "$(assert-arg -- "$FILENAME" 'FILENAME')" trap 'rm -f -- "$FILENAME".embedded-config' EXIT -{ - if head -n1 -- "$FILENAME" | grep -q '^////$'; then - awk 'sep > 1 {exit}; /^\/{4}$/ { sep++; next } { print }' \ - "$FILENAME" - fi -} > "$FILENAME".embedded-config -. "$(realpath -- "$FILENAME".embedded-config)" +awk ' +$0 == "" {exit} +/^= / {next} +{ printf "export %s=\"%s\"\n", + substr($1, 2, length($1) - 2), + substr($0, length($1) + 2) } +' "$FILENAME" > "$FILENAME".embedded-config +. ./"$FILENAME".embedded-config is_article() { printf '%s\n' "$FILENAME" | grep -qE \ -- cgit v1.2.3