scripts: fix link-vmlinux.sh bash-ism
[cascardo/linux.git] / scripts / link-vmlinux.sh
index 86a4fe7..c9a11d1 100755 (executable)
@@ -111,7 +111,6 @@ sortextable()
 }
 
 # Delete output files in case of error
-trap cleanup SIGHUP SIGINT SIGQUIT SIGTERM ERR
 cleanup()
 {
        rm -f .old_version
@@ -124,6 +123,20 @@ cleanup()
        rm -f vmlinux.o
 }
 
+on_exit()
+{
+       if [ $? -ne 0 ]; then
+               cleanup
+       fi
+}
+trap on_exit EXIT
+
+on_signals()
+{
+       exit 1
+}
+trap on_signals HUP INT QUIT TERM
+
 #
 #
 # Use "make V=1" to debug this script
@@ -231,7 +244,6 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
        if ! cmp -s System.map .tmp_System.map; then
                echo >&2 Inconsistent kallsyms data
                echo >&2 Try "make KALLSYMS_EXTRA_PASS=1" as a workaround
-               cleanup
                exit 1
        fi
 fi