commit e9db1f49b75b183c8aeda321ca54aff5b436a4f6
Author:     FRIGN <d...@frign.de>
AuthorDate: Mon Sep 19 22:51:45 2016 +0200
Commit:     FRIGN <d...@frign.de>
CommitDate: Mon Sep 19 22:51:45 2016 +0200

    2ff: use trap to remove temporary file
    
    This also frees us from having to store the return value somewhere.

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

Reply via email to