[TUHS] eqn anomaly

Doug McIlroy doug at cs.dartmouth.edu
Wed Mar 11 11:14:47 AEST 2020

I was surprised that eqn parses the macro call below as having two
arguments, each with an unmatched ".
        define f % $1 %
Ralph Corderoy found that the comma can be hidden by replacing it with
\N'44'. A somewhat cleaner way to hide it is
        define f % $1 %
        define comma % , %
        f(a comma b)
This works too.
        f(f(a comma b))
[Note for cognoscenti. Eqn's practice in expanding macro arguments clashes
with troff's. Eqn expands nested calls after substitution in the outer
macro definition; troff expands while collecting arguments of the outer
call. I've found no documentation of the eqn behavior.]

The classical man page for eqn asserts categorically, `Strings enclosed
in double quotes " " are passed through untouched.'  Unfortunately the
version of Kernighan/Cherry User's Guide that describes macros with
arguments says little about how arguments are parsed except that they
are separated by commas--nothing about whether commas are hidden by
parentheses or quotes.

Certainly splitting at a comma in a quoted string violates the plain
meaning of the man-page assertion. If anyone has v10 (or perhaps something
else after v7) running, I'd be grateful to learn what classic eqn actually
did. I'm morally certain that if it did split and anyone had complained
to Brian, he would have fixed it.

These observations lead me to file a bug report.


More information about the TUHS mailing list