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: Ed Morton
Subject: Re: [bug-gawk] in-place edit request
Date: Mon, 31 Dec 2012 00:30:14 -0600
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/17.0 Thunderbird/17.0

On 12/25/2012 9:40 PM, Eli Zaretskii wrote:
From: Aharon Robbins <address@hidden>
Date: Tue, 25 Dec 2012 22:51:05 +0200
Cc: address@hidden, address@hidden,
  address@hidden, address@hidden

        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
But obviously not for me.

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.
Maybe.  Me, I don't eben understand what you are trying to accomplish,
as you'd be mv'ing the output anyway.


Sorry, I don't know what the process is for how enhancements get implemented: Is there a proposed solution/implementation, now, that we get to agree on (or otherwise!)?

    Ed.



reply via email to

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