xref: /plan9/rc/bin/soelim (revision 81bcec06d2f065e75d849ff0be369337ab66c8a8)
1#!/bin/rc
2# joyless reimplementation of soelim
3# the $0 recursion is a bit ugly
4
5# canonicalise troff commands first with sed into ". so file" form.
6# but the space after the dot has to come out; tbl can't cope with it.
7# friggin' html macros can be longer than two characters; grrr.
8sed '/^[.'']/{
9	s/([^\\])\\".*$/\1/
10#	s/^(.)[	 ]*([^	 \\][^	 \\])[	 ]*/\1 \2 /
11	s/^(.)[	 ]*([^	 \\][^	 \\])/\1 \2/
12}' $* | awk '	BEGIN { me = "'$0'" }
13		$1 !~ /^[.'']$/	{ print; next }
14		$2 == "so" { system(me " " $3) ; next }
15		$2 == "nx" { system(me " " $3) ; exit }
16		{ print }' | sed 's/^([.'']) /\1/'
17