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

Unified · Split

scripts/decodecode+15−2
@@ -6,7 +6,19 @@ · 5 unmodified lines
66 # e.g., to decode an i386 oops on an x86_64 system, use:
77 # AFLAGS=--32 decodecode < 386.oops
88
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"
1022 code=
1123
1224 while read i ; do
@@ -20,6 +32,7 @@ esac · 7 unmodified lines
2032 done
2133
2234 if [ -z "$code" ]; then
35+ rm $T
2336 exit
2437 fi
2538
@@ -48,4 +61,4 @@ echo -n " .byte 0x" > $T.s · 22 unmodified lines
4861 echo $code >> $T.s
4962 as $AFLAGS -o $T.o $T.s
5063 objdump -S $T.o
51−rm $T.o $T.s
64+rm $T $T.s $T.o