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: Wed, 26 Dec 2012 22:22:27 +0200
User-agent: Heirloom mailx 12.5 6/20/10

Hi Andy.

> If using the dup/dup2 approach to operate underneath stdio, I don't
> think there should be a problem.  According to the man page, the dup
> call copies the current file position pointer.

As long as you fflush the output before the call to dup.

> Assaf raised the question of
> robustness with respect to filenames that contain spaces and/or start
> with "-".

Files that start with minus is not an issue.  It's no different than
passing filenames that start with minus straight to gawk.

As to spaces, it means more stuff must be done in C instead of in shell
called from awk.

Here's a cute question for you though. What about if the input filename
is "-" or "/dev/stdin" ?  Yet Another Special Case.

> The inplace_end function could then use the rename system call to avoid
> problems with filenames.  Of course, this assumes that rename works on all
> platforms; is rename portable?

For all the *nix platforms, yes.

Moving on, I didn't look at the strace output in detail.  I'm not sure
I really want to, either. :-)

If you want to pick up this ball and run with it, be my guest. Or, not,
as you like.  If you do try it out, pick a design that looks reasonable
to you and go for it. My advice though is not to over-engineer (spelled
o-b-s-e-s-s :-).

Thanks,

Arnold



reply via email to

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