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
Using .lines on generated data is wrong (traps) #1472
Comments
Also note that my $proc = Proc::Async.new: ‘cat’, ‘file’; # same file as in OP
react {
whenever $proc.stdout.lines { dd $_ }
whenever $proc.start { done }
}
So if you're using Proc::Async, you're doomed. There's RT #131923 which asks for customizable |
From our docs:
Let's see if it helps. my $proc = Proc::Async.new: ‘cat’, ‘file’, :!translate-nl; # same file as in OP
react {
whenever $proc.stdout.lines { dd $_ }
whenever $proc.start { done }
}
Nope. |
Is this issue mistitled? I don't quite understand where the wrongness of calling .lines lies. |
Mistitled or not, I think this is now resolved. |
👍 |
Let's make a file:
perl6 -e 'spurt ‘file’, “foox\nfooy\rbar\nfooz\n”'
It is fair to say (on linux at least) that this file has three lines:
And any proper command line tool in existence will treat it as such.
wc -l
says 3,grep foo
will give the whole line also (your terminal may print it in a weird way, but that's still treated as a whole line).So let's try reading this file in perl 6:
↑ This is entirely right.
But here's a trap:
It turns out that
lines
andslurp.lines
work differently, which is really surprising. Also, I managed to get into this trap at least once.The text was updated successfully, but these errors were encountered: