From 84c2c09ec2889d3caf1841140cc2bcb4ab34228b Mon Sep 17 00:00:00 2001 From: Alexander Bantyev Date: Thu, 23 Mar 2023 19:26:41 +0400 Subject: [PATCH] Manual: fail when #include-d file does not exist --- doc/manual/local.mk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/manual/local.mk b/doc/manual/local.mk index 82c9a87a7..284a85ab5 100644 --- a/doc/manual/local.mk +++ b/doc/manual/local.mk @@ -29,9 +29,11 @@ nix-eval = $(dummy-env) $(bindir)/nix eval --experimental-features nix-command - # re-implement mdBook's include directive to make it usable for terminal output and for proper @docroot@ substitution define process-includes while read -r line; do \ - filename=$$(sed 's/{{#include \(.*\)}}/\1/'<<< $$line); \ - matchline=$$(sed 's|/|\\/|g' <<< $$line); \ - sed -i "/$$matchline/r $$(dirname $(2))/$$filename" $(2); \ + set -euo pipefail; \ + filename="$$(dirname $(2))/$$(sed 's/{{#include \(.*\)}}/\1/'<<< $$line)"; \ + matchline="$$(sed 's|/|\\/|g' <<< $$line)"; \ + test -f "$$filename" || ( echo "#include-d file '$$filename' does not exist." >&2; exit 1; ); \ + sed -i "/$$matchline/r $$filename" $(2); \ sed -i "s/$$matchline//" $(2); \ done < <(grep '{{#include' $(1)) endef