aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-06-23 12:02:47 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-06-23 12:22:30 +0200
commit6711a42d6175984a029e7af7a4886ed44c998e4c (patch)
tree503e5f24c8845184b165126035674808cb703baf
parent4f8e74e9d2183e894dddad9995616d474dc1e07a (diff)
downloadmk-6711a42d6175984a029e7af7a4886ed44c998e4c.tar.gz
toc: Add (toc) prefix to .te output
The original troff cannot disable error output. This patch disambiguates .te's output from troff's normal errors. The (toc) prefix is removed by sed in the toc script.
-rwxr-xr-xtoc/toc38
-rw-r--r--toc/toc.tmac2
2 files changed, 21 insertions, 19 deletions
diff --git a/toc/toc b/toc/toc
index 2b21790..9544934 100755
--- a/toc/toc
+++ b/toc/toc
@@ -3,29 +3,31 @@
# toc -- run troff in three passes
: ${TROFF:=troff}
+SED='sed -n /^(toc)/{s///;p}'
+RM=rm
+
+trap '$RM; RM=; exit 130' INT
+trap '$RM' EXIT
+
+tmp() {
+ x=`mktemp` || exit $?
+ RM=$RM\ $x
+ eval $1=\$x
+}
if [ ! -t 0 ]; then
- f=`mktemp`
+ tmp f
cat > $f
set -- "$@" $f
fi
-if [ -z "$PIPE" ]; then
- g=`mktemp`
- h=`mktemp`
-
- 2>$g >/dev/null $TROFF -rte=1 -rto=0 -E "$@"
- <$g 2>$h >/dev/null $TROFF -rte=1 -rto=1 -E "$@"
- <$h $TROFF -rte=0 -rto=1 "$@"
- s=$?
-
- rm $h $g
-else
- $TROFF -rte=1 -rto=0 -zE "$@" 2>&1 |
- $TROFF -rte=1 -rto=1 -zE "$@" 2>&1 |
- $TROFF -rte=0 -rto=1 "$@"
- s=$?
-fi
+tmp g
+tmp h
+
+$TROFF -rte=1 -rto=0 "$@" 2>&1 1>/dev/null | $SED >$g
+$TROFF -rte=1 -rto=1 "$@" <$g 2>&1 1>/dev/null | $SED >$h
+$TROFF -rte=0 -rto=1 "$@" <$h
+
+s=$?
-[ ! -t 0 ] && rm $f
exit $s
diff --git a/toc/toc.tmac b/toc/toc.tmac
index 143994e..8431e06 100644
--- a/toc/toc.tmac
+++ b/toc/toc.tmac
@@ -15,7 +15,7 @@
.
.\" te -- collect line
.de te
-. if \n(te=1 .tm \$*
+. if \n(te=1 .tm (toc)\$*
..
.
.ec