diff mbox

[RFC,v4,2/4] docker: Fix exit code if $CMD failed

Message ID 1468207242-5015-3-git-send-email-famz@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Fam Zheng July 11, 2016, 3:20 a.m. UTC
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 tests/docker/run | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Eric Blake July 11, 2016, 12:58 p.m. UTC | #1
On 07/10/2016 09:20 PM, Fam Zheng wrote:
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  tests/docker/run | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tests/docker/run b/tests/docker/run
> index 575e732..38ce789 100755
> --- a/tests/docker/run
> +++ b/tests/docker/run
> @@ -11,6 +11,8 @@
>  # or (at your option) any later version. See the COPYING file in
>  # the top-level directory.
>  
> +set -e
> +

'set -e' is a crutch that often does not do what you naively expect. In
particular, it interacts very poorly with shell functions; if 'f' is a
shell function, running 'f' is different than running 'f || alternate',
in whether the body of 'f' will exit early.  I'd much rather script
without having to think about whether 'set -e' is doing the right thing,
because it usually isn't.

>  if test -n "$V"; then
>      set -x
>  fi
> @@ -61,4 +63,6 @@ elif test -n "$DEBUG"; then
>      echo
>      # Force error after shell exits
>      $SHELL && exit 1
> +else
> +    exit 1
>  fi
>
diff mbox

Patch

diff --git a/tests/docker/run b/tests/docker/run
index 575e732..38ce789 100755
--- a/tests/docker/run
+++ b/tests/docker/run
@@ -11,6 +11,8 @@ 
 # or (at your option) any later version. See the COPYING file in
 # the top-level directory.
 
+set -e
+
 if test -n "$V"; then
     set -x
 fi
@@ -61,4 +63,6 @@  elif test -n "$DEBUG"; then
     echo
     # Force error after shell exits
     $SHELL && exit 1
+else
+    exit 1
 fi