Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Capture-Tiny CPAN distribution.

Report information
The Basics
Id: 73374
Status: resolved
Priority: 0/
Queue: Capture-Tiny

People
Owner: Nobody in particular
Requestors: p.herz [...] profihost.ag
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: _slurp - strange when using append file handle?
Date: Tue, 20 Dec 2011 12:28:35 +0100
To: bug-Capture-Tiny [...] rt.cpan.org
From: Philipp Herz - Profihost AG <p.herz [...] profihost.ag>
Hi David, i just tried using Capture::Tiny with two IO::File handles for capturing STDOUT and STDERR in append mode ("a+"). Since i require to investigate (compare) some of the system command's output, i noticed that not only the command's output itself is on OUT handle but the whole content of my logfile, which is obviously not good for comparison. It seems to me, that "_slurp" should better seek for the EOF first. -- Mit freundlichen Grüßen Philipp Herz Ihr Profihost Team ------------------------------- Profihost AG Am Mittelfelde 29 30519 Hannover Deutschland Tel.: +49 (511) 5151 8000 | Fax.: +49 (511) 5151 8299 URL: www.profihost.com | E-Mail: info@profihost.com Sitz der Gesellschaft: Hannover, USt-IdNr. DE813460827 Registergericht: Amtsgericht Hannover, Register-Nr.: HRB 202350 Vorstand: Cristoph Bluhm, Sebastian Bluhm, Stefan Priebe Aufsichtsrat: Prof. Dr. iur. Winfried Huck (Vorsitzender)
Subject: Re: [rt.cpan.org #73374] _slurp - strange when using append file handle?
Date: Wed, 21 Dec 2011 09:50:06 -0500
To: bug-Capture-Tiny [...] rt.cpan.org
From: David Golden <dagolden [...] cpan.org>
On Tue, Dec 20, 2011 at 6:28 AM, Philipp Herz via RT <bug-Capture-Tiny@rt.cpan.org> wrote: Show quoted text
> Since i require to investigate (compare) some of the system command's > output, i noticed that not only the command's output itself is on OUT > handle but the whole content of my logfile, which is obviously not good > for comparison. > > It seems to me, that "_slurp" should better seek for the EOF first.
The documentation states that the files should be empty, so the behavior that you're seeing is "as designed". I can see how you might want to have returned only incremental captures. That actually requires saving the handle position before capture and having _slurp seek to the saved position before slurping. I'll consider that as a wishlist request. Thank you for the suggestion. Regards, David
Subject: Re: [rt.cpan.org #73374] _slurp - strange when using append file handle?
Date: Thu, 22 Dec 2011 12:04:10 +0100
To: bug-Capture-Tiny [...] rt.cpan.org
From: Philipp Herz - Profihost AG <p.herz [...] profihost.ag>
Hey David, good to hear that you might change "behavior as desinged" in the nearer future ;-) Thanks for reply - Philipp Mit freundlichen Grüßen Philipp Herz Ihr Profihost Team ------------------------------- Profihost AG Am Mittelfelde 29 30519 Hannover Deutschland Tel.: +49 (511) 5151 8000 | Fax.: +49 (511) 5151 8299 URL: www.profihost.com | E-Mail: info@profihost.com Sitz der Gesellschaft: Hannover, USt-IdNr. DE813460827 Registergericht: Amtsgericht Hannover, Register-Nr.: HRB 202350 Vorstand: Cristoph Bluhm, Sebastian Bluhm, Stefan Priebe Aufsichtsrat: Prof. Dr. iur. Winfried Huck (Vorsitzender) Am 21.12.2011 15:50, schrieb David Golden via RT: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=73374> > > On Tue, Dec 20, 2011 at 6:28 AM, Philipp Herz via RT > <bug-Capture-Tiny@rt.cpan.org> wrote:
>> Since i require to investigate (compare) some of the system command's >> output, i noticed that not only the command's output itself is on OUT >> handle but the whole content of my logfile, which is obviously not good >> for comparison. >> >> It seems to me, that "_slurp" should better seek for the EOF first.
> > The documentation states that the files should be empty, so the > behavior that you're seeing is "as designed". I can see how you might > want to have returned only incremental captures. That actually > requires saving the handle position before capture and having _slurp > seek to the saved position before slurping. I'll consider that as a > wishlist request. > > Thank you for the suggestion. > > Regards, > David >
This turned out to be easy to test, which made it easy to fix. I've just released version 0.14 which should work the way you want. Please give it a try. Regards, David P.S. Please don't reply to the ticket or it will re-open it. If you want to show thanks, please blog or twitter or whatever about Capture::Tiny instead. :-)
Subject: Re: [rt.cpan.org #73374] _slurp - strange when using append file handle?
Date: Fri, 23 Dec 2011 09:17:05 +0100
To: bug-Capture-Tiny [...] rt.cpan.org
From: Philipp Herz - Profihost AG <p.herz [...] profihost.ag>
Hi David, thanks a lot for updating. Giving the update version a go, i am receiving error messages (when having strict/warnings enabled) Use of uninitialized value $got{"stderr"} in length at Capture/Tiny.pm line 378, <GEN1> line 1. Use of uninitialized value $got{"stdout"} in length at Capture/Tiny.pm line 378, <GEN0> line 1. I (temp) fixed this issue by jumping the for-loop like this: --- Tiny.pm.orig 2011-12-23 08:48:53.428988444 +0100 +++ Tiny.pm 2011-12-23 09:15:15.843257070 +0100 @@ -375,6 +375,7 @@ for ( keys %do ) { _relayer($stash->{capture}{$_}, $layers{$_}); $got{$_} = _slurp($_, $stash); + next if !$got{$_}; _debug("# slurped " . length($got{$_}) . " bytes from $_\n"); } print CT_ORIG_STDOUT $got{stdout} Mit freundlichen Grüßen Philipp Herz Ihr Profihost Team ------------------------------- Profihost AG Am Mittelfelde 29 30519 Hannover Deutschland Tel.: +49 (511) 5151 8000 | Fax.: +49 (511) 5151 8299 URL: www.profihost.com | E-Mail: info@profihost.com Sitz der Gesellschaft: Hannover, USt-IdNr. DE813460827 Registergericht: Amtsgericht Hannover, Register-Nr.: HRB 202350 Vorstand: Cristoph Bluhm, Sebastian Bluhm, Stefan Priebe Aufsichtsrat: Prof. Dr. iur. Winfried Huck (Vorsitzender) Am 22.12.2011 16:18, schrieb David Golden via RT: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=73374> > > This turned out to be easy to test, which made it easy to fix. I've > just released version 0.14 which should work the way you want. Please > give it a try. > > Regards, > David > > P.S. Please don't reply to the ticket or it will re-open it. If you > want to show thanks, please blog or twitter or whatever about > Capture::Tiny instead. :-)
Subject: Re: [rt.cpan.org #73374] _slurp - strange when using append file handle?
Date: Fri, 23 Dec 2011 07:18:55 -0500
To: bug-Capture-Tiny [...] rt.cpan.org
From: David Golden <dagolden [...] cpan.org>
Odd. Could you please send me a code sample that triggers that? Thank you. David On Dec 23, 2011 3:17 AM, "Philipp Herz via RT" <bug-Capture-Tiny@rt.cpan.org> wrote: Show quoted text
> Queue: Capture-Tiny > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=73374 > > > Hi David, > > thanks a lot for updating. > > Giving the update version a go, i am receiving error messages (when > having strict/warnings enabled) > > Use of uninitialized value $got{"stderr"} in length at Capture/Tiny.pm > line 378, <GEN1> line 1. > Use of uninitialized value $got{"stdout"} in length at Capture/Tiny.pm > line 378, <GEN0> line 1. > > > I (temp) fixed this issue by jumping the for-loop like this: > > --- Tiny.pm.orig 2011-12-23 08:48:53.428988444 +0100 > +++ Tiny.pm 2011-12-23 09:15:15.843257070 +0100 > @@ -375,6 +375,7 @@ > for ( keys %do ) { > _relayer($stash->{capture}{$_}, $layers{$_}); > $got{$_} = _slurp($_, $stash); > + next if !$got{$_}; > _debug("# slurped " . length($got{$_}) . " bytes from $_\n"); > } > print CT_ORIG_STDOUT $got{stdout} > > Mit freundlichen Grüßen > Philipp Herz > Ihr Profihost Team > > ------------------------------- > > Profihost AG > Am Mittelfelde 29 > 30519 Hannover > Deutschland > > Tel.: +49 (511) 5151 8000 | Fax.: +49 (511) 5151 8299 > URL: www.profihost.com | E-Mail: info@profihost.com > > Sitz der Gesellschaft: Hannover, USt-IdNr. DE813460827 > Registergericht: Amtsgericht Hannover, Register-Nr.: HRB 202350 > Vorstand: Cristoph Bluhm, Sebastian Bluhm, Stefan Priebe > Aufsichtsrat: Prof. Dr. iur. Winfried Huck (Vorsitzender) > > Am 22.12.2011 16:18, schrieb David Golden via RT:
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=73374> > > > > This turned out to be easy to test, which made it easy to fix. I've > > just released version 0.14 which should work the way you want. Please > > give it a try. > > > > Regards, > > David > > > > P.S. Please don't reply to the ticket or it will re-open it. If you > > want to show thanks, please blog or twitter or whatever about > > Capture::Tiny instead. :-)
> >
Subject: Re: [rt.cpan.org #73374] _slurp - strange when using append file handle?
Date: Fri, 23 Dec 2011 09:43:01 -0500
To: bug-Capture-Tiny [...] rt.cpan.org
From: David Golden <dagolden [...] cpan.org>
Never mind -- must have just been an empty capture and the warning was coming from the do-nothing _debug anyway. I'll fix up _slurp to return empty string when there is nothing captured and comment out the _debug lines as well, as they aren't really needed for production. -- David
Subject: Re: [rt.cpan.org #73374] _slurp - strange when using append file handle?
Date: Fri, 23 Dec 2011 16:14:34 +0100
To: bug-Capture-Tiny [...] rt.cpan.org
From: Philipp Herz - Profihost AG <p.herz [...] profihost.ag>
Hi, sorry for beeing late ;-) I agree that _debug output is not really needed for production there, but anyway i have attached a little example script that triggers this behavior. best regards, Philipp Am 23.12.2011 15:43, schrieb David Golden via RT: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=73374> > > Never mind -- must have just been an empty capture and the warning was > coming from the do-nothing _debug anyway. I'll fix up _slurp to > return empty string when there is nothing captured and comment out the > _debug lines as well, as they aren't really needed for production. > > -- David >

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #73374] _slurp - strange when using append file handle?
Date: Fri, 23 Dec 2011 11:05:29 -0500
To: bug-Capture-Tiny [...] rt.cpan.org
From: David Golden <dagolden [...] cpan.org>
On Fri, Dec 23, 2011 at 10:14 AM, Philipp Herz via RT <bug-Capture-Tiny@rt.cpan.org> wrote: Show quoted text
> I agree that _debug output is not really needed for production there, > but anyway i have attached a little example script that triggers this > behavior.
Thank you. I found the bug and it was somewhat obscure. scalar readline() with $/ undefined returns the empty string, but only for the *first* read to EOF. Your test code was doing multiple captures against the same filehandle, so the second readline gave undef instead of an empty string, thus causing the warning (and violating the API since an empty capture is supposed to return an empty string). I've added a test for repeated reads to the same filehandle and fixed _slurp to ensure an empty string is returned. I'll be releasing 0.15 shortly. -- David