New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-T STDIN hangs #11867
Comments
From @cpansproutIf STDIN is a tty, -T STDIN just hangs waiting for input. Is there such a thing as a non-blocking getc that we can use to solve this? Flags: Site configuration information for perl 5.15.6: Configured by sprout at Sat Dec 31 10:12:16 PST 2011. Summary of my perl5 (revision 5 version 15 subversion 6) configuration: Locally applied patches: @INC for perl 5.15.6: Environment for perl 5.15.6: |
From zefram@fysh.orgFather Chrysostomos wrote:
That sounds like correct behaviour. -T is defined to examine file content. -zefram |
The RT System itself - Status changed from 'new' to 'open' |
From @craigberryOn Mon, Jan 16, 2012 at 7:02 AM, Zefram <zefram@fysh.org> wrote:
But if something is not a file, wouldn't it be fairly safe to say it's |
From tchrist@perl.com"Craig A. Berry" <craig.a.berry@gmail.com> wrote
Yes and no. ==> Yes: If isatty(0) and you're in canonical mode, then that is really ==> No: You can't do it portably without an incredible amount of pain.
Known issue. Way known. Ever since back in 1988 when -T first appeared, I've told people a googolplex
That sounds anything but safe to me. Perl shouldn't make things up. Just because I haven't thought of why there oughtn't be a -f guard "Unix was not designed to stop its users from doing stupid things,
So it can look at the current buffer if it's already got data read into that, If "-T" or "-B" is used on a filehandle, the current IO buffer The problem is what to do if you don't have any of them, since pipes/sockets Because you have to read a file to do the "-T" test, on most So it's not as though they haven't been warned. Repeatedly. For ages. Yes, you can argue that that also means there's a problem. Perhaps --tom |
From @jkeenanOn Mon Jan 16 16:02:32 2012, tom christiansen wrote:
Reviewing the discussion in this older ticket this evening, I believe ##### So I don't see that we have a real bug here. If anyone disagrees, Thank you very much. |
From @cpansproutOn Jan 27, 2013, at 5:31 PM, James E Keenan via RT wrote:
If it is not a bug, then it is a wishlist item. Perl has the feature whereby it will look inside the buffer for -T on something that is not a plain file. If this cannot be relied upon (because one does not know whether the buffer holds anything), then what is the point of having Perl do that? This is a gotcha that *could* be fixed (via a non-blocking read), so I think this ticket should stay open. |
From @epaJames E Keenan via RT <perlbug-followup <at> perl.org> writes:
But the file with name $file could change in between the two tests. You still -f $file && -T _ -- |
From @LeontOn Mon, Jan 28, 2013 at 7:02 AM, Father Chrysostomos <sprout@cpan.org> wrote:
I'm not sure non-blocking reads can easily be done portably. Not sure Leon |
From @LeontOn Mon, Jan 28, 2013 at 12:19 PM, Ed Avis <eda@waniasset.com> wrote:
_ is the old stat buffer, which isn't enough for -T. -f $fh && -T $fh Leon |
From @epaLeon Timmermans <fawaka <at> gmail.com> writes:
So then the safe way to do it is to stat an open filehandle? open my $fh, '<', $file or die "cannot open Perhaps -T should do this internally so that it cannot hang? -- |
From @jkeenanOn Sun Jan 27 17:31:08 2013, jkeenan wrote:
Since there has been further discussion, meaning that the ticket cannot |
From zefram@fysh.orgA couple of points have been missed in this discussion. Firstly, the $ perl -lwe 'print -T "/dev/null" || 0; print -T "/dev/zero" || 0' Secondly, there's been a bit of the mistaken idea that a non-regular # -f File is a plain file. Given that understanding of what "file" means in this document, we can # -T File is an ASCII or UTF-8 text file (heuristic guess). It speaks of examining the content of "the file". Doesn't say anything Clearly, reading from non-regular files is intentional behaviour, This ticket should be closed. -zefram |
From @jkeenanOn Tue, 14 Nov 2017 21:42:02 GMT, zefram@fysh.org wrote:
I attempted to wrap up discussion on this ticket and close it almost five years ago -- and failed! So I'll take that recommendation and try to get it done for real now. Closing. Thank you very much. -- |
@jkeenan - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#108278 (status was 'rejected')
Searchable as RT108278$
The text was updated successfully, but these errors were encountered: