History

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.

Randy Dunlap committed 18 years ago

Commit fa220d81 parent 80daa561 file · +15 −2Browse files

Showing the changes to scripts/decodecode (1 of 1 file). Show all

Unified · Split

scripts/decodecode+15−2
@@ -6,7 +6,19 @@ · 5 unmodified lines
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.oops7# AFLAGS=--32 decodecode < 386.oops
8 8
9T=`mktemp`9cleanup() {
10 rm -f $T $T.s $T.o
11 exit 1
12}
13
14die() {
15 echo "$@"
16 exit 1
17}
18
19trap cleanup EXIT
20
21T=`mktemp` || die "cannot create temp file"
10code=22code=
11 23
12while read i ; do24while read i ; do
@@ -20,6 +32,7 @@ esac · 7 unmodified lines
20done32done
21 33
22if [ -z "$code" ]; then34if [ -z "$code" ]; then
35 rm $T
23 exit36 exit
24fi37fi
25 38
@@ -48,4 +61,4 @@ echo -n " .byte 0x" > $T.s · 22 unmodified lines
48echo $code >> $T.s61echo $code >> $T.s
49as $AFLAGS -o $T.o $T.s62as $AFLAGS -o $T.o $T.s
50objdump -S $T.o63objdump -S $T.o
51rm $T.o $T.s64rm $T $T.s $T.o