diff options
author | John Ankarström <john@ankarstrom.se> | 2021-06-23 12:02:47 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-06-23 12:22:30 +0200 |
commit | 6711a42d6175984a029e7af7a4886ed44c998e4c (patch) | |
tree | 503e5f24c8845184b165126035674808cb703baf /toc | |
parent | 4f8e74e9d2183e894dddad9995616d474dc1e07a (diff) | |
download | mk-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.
Diffstat (limited to 'toc')
-rwxr-xr-x | toc/toc | 38 | ||||
-rw-r--r-- | toc/toc.tmac | 2 |
2 files changed, 21 insertions, 19 deletions
@@ -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 |