2 # grog -- guess options for groff command
3 # Like doctype in Kernighan & Pike, Unix Programming Environment, pp 306-8.
17 opts
="$opts $arg"; shift;;
23 egrep -h '^\.(P|[LI]P|[pnil]p|TS|EQ|TH|SH|so)' $
* \
24 |
sed -e '/^\.so/s/^.*$/.SO_START\
28 |
egrep '^\.(P|[LI]P|[pnil]p|TS|EQ|TH|SH|SO_START|SO_END)' \
30 /^\.SO_START$/ { so = 1 }
31 /^\.SO_END$/ { so = 0 }
32 /^\.TS/ { tbl++; if (so > 0) soelim++ }
33 /^\.PS/ { pic++; if (so > 0) soelim++ }
34 /^\.EQ/ { eqn++; if (so > 0) soelim++ }
45 if (pic > 0 || tbl > 0 || eqn > 0) {
47 if (soelim > 0) printf "s"
48 if (pic > 0) printf "p"
49 if (tbl > 0) printf "t"
50 if (eqn > 0) printf "e"
54 else if (SH > 0 && TH > 0)
65 }' "opts=$opts" "files=$*" -