Skip to content

Commit fa220d8

Browse files
rddunlapsravnborg
authored andcommitted
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>
1 parent 80daa56 commit fa220d8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

scripts/decodecode

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@
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
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
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

0 commit comments

Comments
 (0)