diff mbox

[kvm-unit-tests,v2,04/12] scripts/mkstandalone: improve exit paths

Message ID 1450374823-7648-5-git-send-email-rkrcmar@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Radim Krčmář Dec. 17, 2015, 5:53 p.m. UTC
trap can be called on EXIT, which covers most exits.

Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
---
 v2: new
 
 scripts/mkstandalone.sh | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Andrew Jones Dec. 17, 2015, 7:15 p.m. UTC | #1
On Thu, Dec 17, 2015 at 06:53:35PM +0100, Radim Kr?má? wrote:
> trap can be called on EXIT, which covers most exits.

Not with dash :-) If we decide to depend on bash, then

Reviewed-by: Andrew Jones <drjones@redhat.com>

> 
> Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
> ---
>  v2: new
>  
>  scripts/mkstandalone.sh | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
> index cf2182dbd936..778383077769 100755
> --- a/scripts/mkstandalone.sh
> +++ b/scripts/mkstandalone.sh
> @@ -71,7 +71,7 @@ exit 1
>  EOF
>  else
>  	cat <<EOF >> $standalone
> -trap 'rm -f \$bin; exit 1' HUP INT TERM
> +trap 'rm -f \$bin' EXIT
>  bin=\`mktemp\`
>  base64 -d << 'BIN_EOF' | zcat > \$bin &&
>  EOF
> @@ -107,10 +107,7 @@ __run()
>  __eval_log() { eval "\${@}"; }
>  
>  run `escape "${@}"`
> -ret=$?
> -
> -rm -f \$bin
> -exit \$ret
> +exit \$?
>  EOF
>  fi
>  chmod +x $standalone
> -- 
> 2.6.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
index cf2182dbd936..778383077769 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -71,7 +71,7 @@  exit 1
 EOF
 else
 	cat <<EOF >> $standalone
-trap 'rm -f \$bin; exit 1' HUP INT TERM
+trap 'rm -f \$bin' EXIT
 bin=\`mktemp\`
 base64 -d << 'BIN_EOF' | zcat > \$bin &&
 EOF
@@ -107,10 +107,7 @@  __run()
 __eval_log() { eval "\${@}"; }
 
 run `escape "${@}"`
-ret=$?
-
-rm -f \$bin
-exit \$ret
+exit \$?
 EOF
 fi
 chmod +x $standalone