summaryrefslogtreecommitdiff
path: root/2ff
diff options
context:
space:
mode:
authorFRIGN <dev@frign.de>2016-09-19 22:51:45 +0200
committerFRIGN <dev@frign.de>2016-09-19 22:51:45 +0200
commite9db1f49b75b183c8aeda321ca54aff5b436a4f6 (patch)
tree551aa485d16b2d364539115c49c65aee7468d8e1 /2ff
parent48c52a1f4889858ae3466f1987b522e426b6ddf3 (diff)
2ff: use trap to remove temporary file
This also frees us from having to store the return value somewhere.
Diffstat (limited to '2ff')
-rwxr-xr-x2ff10
1 files changed, 5 insertions, 5 deletions
diff --git a/2ff b/2ff
index 9a252a9..bf58e5b 100755
--- a/2ff
+++ b/2ff
@@ -5,6 +5,8 @@ if [ "$#" -ne 0 ]; then
fi
TMP=$(mktemp)
+trap 'rm "$TMP"' EXIT
+
cat > "$TMP"
if [ "$(dd if="$TMP" bs=1 count=8 2>/dev/null)" = "farbfeld" ]; then
@@ -26,11 +28,9 @@ image/jpeg)
;;
esac
-ret=$?
-rm "$TMP"
-
-if [ $ret -ne 0 ]; then
+if [ $? -ne 0 ]; then
printf "%s: failed to convert from %s\n" "$0" "$FORMAT" >&2
+ exit 1
fi
-exit $ret
+exit 0