lkml.org 
[lkml]   [2015]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 03/45] headers_install.sh: enhance error handling
Date
Exit with error if using undefined variables or if any sub command fails
with error return value. unidef needs special handling since but this can
be done without the trap. Enables exaniming intermediate files if some
commands failed.

Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
---
scripts/headers_install.sh | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
index fdebd66..072f7d3 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -1,4 +1,7 @@
#!/bin/sh
+set -e
+set -u
+#set -x

if [ $# -lt 2 ]
then
@@ -26,7 +29,6 @@ shift
# Iterate through files listed on command line

FILE=
-trap 'rm -f "$OUTDIR/$FILE" "$OUTDIR/$FILE.sed"' EXIT
for i in "$@"
do
FILE="$(basename "$i")"
@@ -37,10 +39,13 @@ do
-e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
-e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \
-e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \
- "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1
+ "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || \
+ ( rm -f "$OUTDIR/$FILE.sed" ; exit 1 )
scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \
- > "$OUTDIR/$FILE"
- [ $? -gt 1 ] && exit 1
+ > "$OUTDIR/$FILE" || \
+ ( if [ $? -gt 1 ]; then \
+ rm -f "$OUTDIR/$FILE" "$OUTDIR/$FILE.sed" ; \
+ exit 1 ; \
+ fi )
rm -f "$OUTDIR/$FILE.sed"
done
-trap - EXIT
--
2.1.4


\
 
 \ /
  Last update: 2015-02-17 00:21    [W:0.852 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site