run command: fix matching \r\n and use non-capturing group for it

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-08-19 08:54:08 +02:00
parent cb9db10c1a
commit ba104d6760

View File

@ -497,7 +497,7 @@ sub run_command {
if ($h eq $reader) {
if ($outfunc || $logfunc) {
eval {
while ($buf =~ s/^([^\010\r\n]*)(\r|\n|(\010)+|\r\n)//) {
while ($buf =~ s/^([^\010\r\n]*)(?:\n|(?:\010)+|\r\n?)//) {
my $line = $outlog . $1;
$outlog = '';
&$outfunc($line) if $outfunc;
@ -518,7 +518,7 @@ sub run_command {
} elsif ($h eq $error) {
if ($errfunc || $logfunc) {
eval {
while ($buf =~ s/^([^\010\r\n]*)(\r|\n|(\010)+|\r\n)//s) {
while ($buf =~ s/^([^\010\r\n]*)(?:\n|(?:\010)+|\r\n?)//) {
my $line = $errlog . $1;
$errlog = '';
&$errfunc($line) if $errfunc;