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

Andrew Jones
2015-12-17T19:15:28Z

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