On Thu, Nov 27, 2008 at 03:30:07AM -0800, Chip Salzenberg wrote:
> On Wed, Nov 26, 2008 at 11:32:31PM -0800, Chip Salzenberg wrote:
> > On Wed, Nov 26, 2008 at 05:09:22PM -0800, Chip Salzenberg wrote:
> > > Yay. Action item #1: die on output failure in a -i loop.
> > And here's the patch for this part of the larger issue of not ignoring flush
> > and close errors.
> ... but it also fails lib/warnings.t.
But not any more! Here's a new cut. It only reports flush failures caused
by system call failure, not previously noted failures recorded as ferror(fp).
diff --git a/doio.c b/doio.c
index c945216..ce57ae1 100644
--- a/doio.c
+++ b/doio.c
@@ -904,7 +904,14 @@ Perl_nextargv(pTHX_ register GV *gv)
if (io && (IoFLAGS(io) & IOf_ARGV))
IoFLAGS(io) |= IOf_START;
if (PL_inplace) {
- (void)do_close(PL_argvoutgv,FALSE);
+ IO *outio;
+ if (PL_argvoutgv && isGV_with_GP(PL_argvoutgv) && (outio = GvIO(PL_argvoutgv))) {
+ dSAVE_ERRNO;
+ SETERRNO(0, 0);
+ if (!io_close(outio, FALSE) && errno) /* only report _new_ failure to flush */
+ Perl_die(aTHX_ "-p destination: %s", Strerror(errno));
+ RESTORE_ERRNO;
+ }
if (io && (IoFLAGS(io) & IOf_ARGV)
&& PL_argvout_stack && AvFILLp(PL_argvout_stack) >= 0)
{
--
Chip Salzenberg twitter:chipsalz
"UTOPIA PLANITIA IS IN ORBIT is the new HAN SHOT FIRST" - Crisper Than Thou
Thread Previous
|
Thread Next