groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] option to set output file name


From: Ralph Corderoy
Subject: Re: [Groff] option to set output file name
Date: Wed, 29 Apr 2009 09:15:06 +0100

Hi Michail,

> may be I am missing something trivial, but I can not find a
> command-line switch in groff to direct output to file.

No, I'm pretty certain there isn't one.

> Output redirection is no problem in shell scripts, but if groff is to
> be spawned from another program it becomes a problem, either you spawn
> a shell runing a script or spawn groff and have to bother with piping
> output. You can not just fire off groff and forget about it. What a
> miss :(

When you say "spawn a shell runing a script" I assume you know you can
give the shell a command to execute with the -c option without a script
file needing to exist on disc?  For example, in C,

    ret = system("groff foo.tr >foo.ps");

will cause sh(1) to be execve(2)'d with

    execve("/bin/sh", ["sh", "-c", "groff foo.tr >foo.ps"], [/* 55 vars */])

So yes, that does involve a shell being started just to run groff, but
then you're wanting the shell's I/O redirection syntax to be
interpreted.  As I think you're saying, you could avoid this by manually
forking and setting up file descriptor 0 to be writing to foo.ps before
execing groff but it's hassle and system() is just easier.

An option shouldn't be added to groff to do this.  By that logic, awk,
sed, make, date, and wc should all grow an --output option too.

Cheers,


Ralph.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]