From e0cabd2caad4fd64893b1589ad36824ac0cf61e2 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 29 Oct 2012 09:45:50 +0100 Subject: [PATCH] fix bug #264: use option pipefail for shell commands Normal unix shell pipe return the exits status of the last command. If pipefail is enabled, the pipeline's return status is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands exit successfully. --- Makefile | 2 +- data/PVE/Tools.pm | 7 ++++++- debian/changelog | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f6571e7..94fcaf7 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ RELEASE=2.2 VERSION=1.0 -PKGREL=36 +PKGREL=37 PACKAGE=libpve-common-perl diff --git a/data/PVE/Tools.pm b/data/PVE/Tools.pm index 43b30b1..27b4361 100644 --- a/data/PVE/Tools.pm +++ b/data/PVE/Tools.pm @@ -207,7 +207,12 @@ sub run_command { if (!ref($cmd)) { $cmdstr = $cmd; - $cmd = [ $cmd ]; + if ($cmd =~ m/|/) { + # see 'man bash' for option pipefail + $cmd = [ '/bin/bash', '-c', "set -o pipefail && $cmd" ]; + } else { + $cmd = [ $cmd ]; + } } else { $cmdstr = cmd2string($cmd); } diff --git a/debian/changelog b/debian/changelog index fc27fdf..3d32611 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +libpve-common-perl (1.0-37) unstable; urgency=low + + * fix bug #264: use option pipefail for shell commands + + -- Proxmox Support Team Mon, 29 Oct 2012 09:45:11 +0100 + libpve-common-perl (1.0-36) unstable; urgency=low * new helper wait_for_vnc_port() -- 2.39.2