commit d6151abb125085285a72a77966bbb68e40484bf7
parent 48ffd5a66c291bb2619b9f29958aa32a716e95ef
Author: Kyle Milz <krwmilz@gmail.com>
Date: Tue, 27 Jul 2021 05:54:31 +0000
mk: add .sh support to xliterate
I want to #include shell scripts literally in documents, implement document
and test it.
Diffstat:
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/bsd.html.mk b/bsd.html.mk
@@ -116,9 +116,9 @@ depend: ${SRCS:.in=.depend} _SUBDIRUSE
# Note dependency file names must be unique for this inference because all
# target files will have .xliterate suffix.
#
-.SUFFIXES: .c .html .in .txt
+.SUFFIXES: .c .html .in .sh .txt
.SUFFIXES: .xliterate
-.c.xliterate .html.xliterate .in.xliterate .txt.xliterate:
+.c.xliterate .html.xliterate .in.xliterate .sh.xliterate .txt.xliterate:
sed \
-e "s/</\</g" \
-e "s/>/\>/g" \
diff --git a/html.mk.5 b/html.mk.5
@@ -199,6 +199,8 @@ The following source file suffixes are supported:
.It
.Pa .html
.It
+.Pa .sh
+.It
.Pa .txt
.El
.Pp
diff --git a/t/xliterate.t b/t/xliterate.t
@@ -12,9 +12,10 @@ my $html_mk = $cmd->here . "/bsd.html.mk";
$cmd->write( 'c_frag.c', '#include <stdio.h>' );
$cmd->write( 'html_frag.html', '<head><body> <img /> </body>' );
-$cmd->write( 'in_frag.xliterate', 'line one \n
+$cmd->write( 'in_frag.in', 'line one \n
line two' );
-$cmd->write( 'txt_frag.xliterate', 'whatever' );
+$cmd->write( 'txt_frag.txt', 'whatever' );
+$cmd->write( 'sh_frag.sh', '#!/bin/sh' );
$cmd->write( 'index.in', <<EOF );
#include "c_frag.xliterate"
@@ -24,6 +25,8 @@ $cmd->write( 'index.in', <<EOF );
#include "in_frag.xliterate"
--
#include "txt_frag.xliterate"
+--
+#include "sh_frag.xliterate"
EOF
$cmd->write( 'Makefile', <<EOF );
@@ -52,10 +55,12 @@ my $good = <<'EOF';
--
<head><body> <img /> </body>
--
-line one \n
+line one \n
line two
--
whatever
+--
+#!/bin/sh
EOF
file_contents_eq_or_diff( $cmd->workdir . "/index.html", $good,