bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] in-place edit request


From: Aharon Robbins
Subject: Re: [bug-gawk] in-place edit request
Date: Tue, 25 Dec 2012 22:51:05 +0200
User-agent: Heirloom mailx 12.5 6/20/10

Hi Eli.

> > then to restore
> > 
> >     char buf[100];  /* say */
> >     sprintf(buf, "/dev/fd/%d", save_fd);
> > 
> >     fp = freopen(buf, "w", stdout);
> >     close(save_fd);
> >     save_fd = -1;
> > 
> > Ta da!
> > 
> > Details left as an exercise for the reader.
>
> But /dev/fd/N is not portable :-(

Solaris, Linux, *BSD, Mac OS X, Cygwin.  Portable enough for me (especially
as someone else[1] is going to write the proposed extension under discussion).

I suspect that some combination of dup, fileno, freopen, fdopen, and
*stdout = *fp / *fp = *stdout could be made to work on systems not
supporting /dev/fd.

Thanks,

Arnold

[1] C.f. the "somebody else's problem field" from HGTTG.  :-)



reply via email to

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