openSUSE / Mojo-IOLoop-ReadWriteProcess

Execute external programs or internal code blocks as separate process
Other
10 stars 13 forks source link

Fix _getlines() don't add extra '\n' string in scalar context #16

Closed cfconrad closed 2 years ago

cfconrad commented 2 years ago

This fix all methods which use _getlines() underneath, e.g. read_all_stdout(). In scalar context, this function return a join() version of IO::Handle::getlines(). With this fix, we avoid the extra added '\n' string.

cfconrad commented 2 years ago

Exactly, this https://github.com/os-autoinst/os-autoinst/pull/1855 is where it comes from.

Just use this snippet to reproduce:

use Mojo::Base -strict;
use Mojo::IOLoop::ReadWriteProcess "process";
say scalar(process(sub { say $_ for (1..10)})->start->wait_stop()->read_all_stdout());