Hi all, I have a bunch of macros which take flags like -c, -nr etc. I wrote a getopt-like parser macro which works something like this:
caller: .getopt:setup c nr: .getopt:parse \\$@ .shift \\n[getopt:nshift] getopt:parse: .has-prefix - "\\$1" .while \\n[has-prefix?] \{\ . \" ... . shift . has-prefix - "\\$1" .\} has-prefix: .nr has-prefix? 0 .ds _str "\\$2\" .\" the end index is calculated based on $1's length .\" but it's equivalent to this in this particular case: .substring _str 0 0 .ie '\\*[_str]'\\$1' .nr has-prefix? 1 Recently I ran into this problem: troff: backtrace: macro 'has-prefix' troff: backtrace: while loop troff: backtrace: macro 'getopt:parse' warning: missing closing delimiter in output comparison operator (got a newline) A added a print statement before the conditional in has-prefix, like so: .tm .ie '\\*[_str]'\\$1' and got: .ie '\'-' Is there any way out of this? groff(7) has this to say: Surround the comparands with \? to avoid formatting them; this causes them to be compared character by character, as with string comparisons in other programming languages. Since comparands protected with \? are read in copy mode, they need not even be valid groff syntax. The escape character is still lexically recognized, however, and consumes the next character. The last sentence leads me to believe the answer is no. Thanks in advance for any enlightening ideas, ~ onf