soelim 590 B

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