From 818d297b17a55fc9c3b21784f45b23875501d654 Mon Sep 17 00:00:00 2001 From: Eric Garver Date: Mon, 17 Jun 2019 10:57:55 -0400 Subject: [PATCH 04/20] test: new macro PIPESTATUS0 It's essentially a portable version of bash's PIPESTATUS[0]. It passes down the return code of the first command in the pipeline. (cherry picked from commit 1c4bb9337f5d5c734a2a8bab10782423408d4026) --- src/tests/functions.at | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tests/functions.at b/src/tests/functions.at index 800dd92c7826..932e288f1597 100644 --- a/src/tests/functions.at +++ b/src/tests/functions.at @@ -242,6 +242,14 @@ m4_define([NS_CHECK], [ AT_CHECK([NS_CMD([$1])], [$2], [$3], [$4], [$5], [$6]) ]) +dnl implement PIPESTATUS[0] in a portable way +dnl +m4_define([PIPESTATUS0], [dnl + sh <<-"HERE" + { { { { $1; echo $? >&3; } | $2 >&4; } 3>&1; } | { read RC; exit $RC; } } 4>&1 +HERE +]) + m4_define([EBTABLES_LIST_RULES], [ dnl ebtables commit 5f508b76a0ce change list output for inversion. m4_define([EBTABLES_LIST_RULES_NORMALIZE], [[sed -e 's/\([-][-][-a-zA-Z0-9]\+\)[ ]\+[!]/! \1/g']]) -- 2.20.1