On 19/02/10 06:04:13, Larry Kollar wrote:
> In my Makefile, I use 2> to redirect stderr to a file:
> 
>       groff $(FLAGS) -rTocGen=1 -z stuff bookfile.ms 2>bookfile.aux
>       ## do stuff with the aux file ##
>       groff $(FLAGS) stuff bookfile.ms >bookfile.ps 2>bookfile.err
> 
> The TocGen register turns on all the stuff needed for contents, 
> cross-
> 
> refs, and index; it's all output using .tm.

I also use Larry's method to generate indexes, lists and the like. It 
permits external formatting which is lot easier than trying to do so 
from within the groff input file.

I also use .tm to "calculate" the last page for those occasions when I 
need "Page % of N".

TotalPs="$(groff $(FLAGS) -iz  "input" -<<< '.tm \n%' 2>&1>/dev/null)"

$TotalPs is then tested for numeric value to determine whether STDERR 
contains anything other than a number (or a number within a specified 
range) before being used on the next run to populate the appropriate 
register.

The use of both the "z" switch and the redirection of STDOUT to /dev/
null is not belt & braces, it prevents the output of an additional 
newline.

I would hazard the guess that redirection of STDERR from the command 
line would obviate the need for redirecting .tm itself from within 
groff. Is there *any* situation where a file created by .tm requests 
would *not* require inspection and/or further manipulation by hand 
before being included back into the book?

Robert Thorsby



Reply via email to