Skip to content

Commit

Permalink
kbuild: minor scripts/decodecode update
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Sam Ravnborg <[email protected]>
  • Loading branch information
rddunlap authored and sravnborg committed Jan 28, 2008
1 parent 80daa56 commit fa220d8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripts/decodecode
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@
# e.g., to decode an i386 oops on an x86_64 system, use:
# AFLAGS=--32 decodecode < 386.oops

T=`mktemp`
cleanup() {
rm -f $T $T.s $T.o
exit 1
}

die() {
echo "$@"
exit 1
}

trap cleanup EXIT

T=`mktemp` || die "cannot create temp file"
code=

while read i ; do
Expand All @@ -20,6 +32,7 @@ esac
done

if [ -z "$code" ]; then
rm $T
exit
fi

Expand Down Expand Up @@ -48,4 +61,4 @@ echo -n " .byte 0x" > $T.s
echo $code >> $T.s
as $AFLAGS -o $T.o $T.s
objdump -S $T.o
rm $T.o $T.s
rm $T $T.s $T.o

0 comments on commit fa220d8

Please sign in to comment.