diff options
author | Randy Dunlap <randy.dunlap@oracle.com> | 2008-01-14 18:18:31 -0500 |
---|---|---|
committer | Sam Ravnborg <sam@ravnborg.org> | 2008-01-28 17:14:40 -0500 |
commit | fa220d89ad050cf5d970c0418ded019a80efedfb (patch) | |
tree | 6148ecb571839fbc253582f86d4c7f9161b1e7d7 /scripts | |
parent | 80daa56008dad44f08d0b47670cf2513aa98ab53 (diff) |
kbuild: minor scripts/decodecode update
Remove the tmp file when exiting. Noticed by Arjan van de Ven.
Catch mktemp failure and exit with message.
Trap kill or other signals and exit cleanly.
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/decodecode | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/scripts/decodecode b/scripts/decodecode index 1e1a8f620c47..235d3938529d 100644 --- a/scripts/decodecode +++ b/scripts/decodecode | |||
@@ -6,7 +6,19 @@ | |||
6 | # e.g., to decode an i386 oops on an x86_64 system, use: | 6 | # e.g., to decode an i386 oops on an x86_64 system, use: |
7 | # AFLAGS=--32 decodecode < 386.oops | 7 | # AFLAGS=--32 decodecode < 386.oops |
8 | 8 | ||
9 | T=`mktemp` | 9 | cleanup() { |
10 | rm -f $T $T.s $T.o | ||
11 | exit 1 | ||
12 | } | ||
13 | |||
14 | die() { | ||
15 | echo "$@" | ||
16 | exit 1 | ||
17 | } | ||
18 | |||
19 | trap cleanup EXIT | ||
20 | |||
21 | T=`mktemp` || die "cannot create temp file" | ||
10 | code= | 22 | code= |
11 | 23 | ||
12 | while read i ; do | 24 | while read i ; do |
@@ -20,6 +32,7 @@ esac | |||
20 | done | 32 | done |
21 | 33 | ||
22 | if [ -z "$code" ]; then | 34 | if [ -z "$code" ]; then |
35 | rm $T | ||
23 | exit | 36 | exit |
24 | fi | 37 | fi |
25 | 38 | ||
@@ -48,4 +61,4 @@ echo -n " .byte 0x" > $T.s | |||
48 | echo $code >> $T.s | 61 | echo $code >> $T.s |
49 | as $AFLAGS -o $T.o $T.s | 62 | as $AFLAGS -o $T.o $T.s |
50 | objdump -S $T.o | 63 | objdump -S $T.o |
51 | rm $T.o $T.s | 64 | rm $T $T.s $T.o |