Skip to content
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

Rakudo hangs if you try to read $*IN when -n is used (perl6 -ne 'say $*IN.get' file) #5286

Closed
p6rt opened this issue May 1, 2016 · 8 comments

Comments

@p6rt
Copy link

p6rt commented May 1, 2016

Migrated from rt.perl.org#128046 (status was 'rejected')

Searchable as RT128046$

@p6rt
Copy link
Author

p6rt commented May 1, 2016

From @AlexDaniel

So, in this bug report we will be attempting to read $*IN when we are already
reading it because of the -n flag.

$*IN.get() hangs if the file is listed as an argument, but does not hang if it is piped

Command​:
perl6 -ne 'say $*IN.get' /etc/passwd
Or
perl6 -ne 'say $*IN.lines' /etc/passwd

Result​:
(nothing, it hangs!)

Interestingly, it does not hang if instead of listing the files you actually pipe something​:

Command​:
perl6 -ne 'say $*IN.get' < /etc/passwd

Result​:
(prints a bunch of stuff)

Now, obviously, it is a little bit weird for the user to try to read from $*IN when -n flag is
in place, but there is at least one documented case of accidental use :) http://irclog.perlgeek.de/perl6/2016-05-01#i_12416462

Also, since it does not hang if proper STDIN is present, I think that it should work.

@p6rt
Copy link
Author

p6rt commented May 1, 2016

@p6rt
Copy link
Author

p6rt commented May 1, 2016

From @geekosaur

On Sun, May 1, 2016 at 7​:11 AM, Alex Jakimenko <perl6-bugs-followup@​perl.org

wrote​:

Now, obviously, it is a little bit weird for the user to try to read from
$*IN when -n

Not that weird. Let the loop read chunk headers, and read/process the rest
of the chunk in the middle of the loop. It's used that way in perl5 and
other languages fairly often.

--
brandon s allbery kf8nh sine nomine associates
allbery.b@​gmail.com ballbery@​sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

@p6rt
Copy link
Author

p6rt commented May 1, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jul 9, 2016

From @zoffixznet

The code you provided doesn't hang, it waits for input from $*IN. If you type enough (or press ^D), the program will run. -n flag sets $_ to each line of the given file.

Would you please clarify what the problematic issue is?

@p6rt
Copy link
Author

p6rt commented Jul 9, 2016

From @AlexDaniel

On 2016-07-09 10​:51​:13, cpan@​zoffix.com wrote​:

The code you provided doesn't hang, it waits for input from $*IN. If
you type enough (or press ^D), the program will run. -n flag sets $_
to each line of the given file.

Would you please clarify what the problematic issue is?

Right! Right… For some reason I was assuming that stdin will be substituted with file contents, hmm.

If it is supposed to be this way, then yeah, there's no problem, and we can probably reject this. But do we need a test?

@p6rt
Copy link
Author

p6rt commented Jul 18, 2016

From @zoffixznet

If there's no bug, then I'll close this without tests.

If any general tests aren't complete for the methods involved in the report, they will be added as part of my upcoming work to increase roast coverage.

--
Cheers,
ZZ | https://twitter.com/zoffix

@p6rt p6rt closed this as completed Jul 18, 2016
@p6rt
Copy link
Author

p6rt commented Jul 18, 2016

@zoffixznet - Status changed from 'open' to 'rejected'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant