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

Radim Krčmář
2015-12-17T17:54:07Z

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(-)

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