From de57efff82bda540cea378029e0233b13e7715a5 Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Thu, 12 Jul 2018 13:50:07 +0200 Subject: [PATCH] btrbk: bugfix: print all errors if send/receive fails If stream_compress is enabled and compress command is not found, we now print "command not found". --- btrbk | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/btrbk b/btrbk index 10dcb40..10f2674 100755 --- a/btrbk +++ b/btrbk @@ -1422,17 +1422,12 @@ sub btrfs_send_receive($$$$) $ret = $err; # print the errors below } if(defined($ret)) { - # NOTE: if "btrfs send" fails, "btrfs receive" returns 0! so we need to parse the output... - foreach(split("\n", $ret)) { - if(/^ERROR: /) { - ERROR $'; - $send_receive_error = 1; - } - elsif(/^WARNING: /) { - WARN "[send/receive] (send=$snapshot_path, receive=$target_path) $'"; - } - else { - WARN "[send/receive] (send=$snapshot_path, receive=$target_path) $_" if($send_receive_error); + # NOTE: btrfs-progs < 4.11: if "btrfs send" fails, "btrfs receive" returns 0! so we need to parse the output for "ERROR:" lines: + my @ret_lines = split("\n", $ret); + $send_receive_error = 1 if(grep /^ERROR: /, @ret_lines); + foreach(@ret_lines) { + if(/^WARNING: / || $send_receive_error) { + WARN "[send/receive] (send=$snapshot_path, receive=$target_path) $_"; } } }