diff options
author | eldritch horrors <pennae@lix.systems> | 2024-03-29 20:06:55 +0100 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-03-30 14:26:47 +0000 |
commit | 65d544b1a631a139c369387618adbb2fe2fe9e1f (patch) | |
tree | d49ebbdbf8de003cd89e3fb97085cf1e4900725f /doc/manual/process-includes.sh | |
parent | a4f5bb951dbc6fa4ffa2bb56376b38f38b6e9154 (diff) |
build: extract make "functions" into scripts
we'll want to use these for the meson builds, and probably eventually
rewrite them in something that isn't plain shell. diffoscope confirms
that out/share and doc/share are equal before and after these changes
Change-Id: I49aa418fc8615cad86d67328e08c28a7405ec952
Diffstat (limited to 'doc/manual/process-includes.sh')
-rwxr-xr-x | doc/manual/process-includes.sh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/manual/process-includes.sh b/doc/manual/process-includes.sh new file mode 100755 index 000000000..6d75710ad --- /dev/null +++ b/doc/manual/process-includes.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -euo pipefail + +# re-implement mdBook's include directive to make it usable for terminal output and for proper @docroot@ substitution +(grep '{{#include' "$1" || true) | while read -r line; do + filename="$(dirname "$1")/$(printf "$line" | sed 's/{{#include \(.*\)}}/\1/')" + test -f "$filename" || ( echo "#include-d file '$filename' does not exist." >&2; exit 1; ) + matchline="$(printf "$line" | sed 's|/|\\/|g')" + sed -i "/$matchline/r $filename" "$2" + sed -i "s/$matchline//" "$2" +done |