]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Tools.pm
run command: fix matching \r\n and use non-capturing group for it
[pve-common.git] / src / PVE / Tools.pm
index d9c69e3d803683460ac7b7c95981e3d9d1e8e306..f9270d9b10340eec789346e81f4a926772ccabfd 100644 (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;