linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mikko Rapeli <mikko.rapeli@iki.fi>
To: linux-kernel@vger.kernel.org
Cc: linux-kbuild@vger.kernel.org, mikko.rapeli@iki.fi
Subject: [RFC PATCH v2 04/27] headers_install.sh: enhance error handling
Date: Mon,  1 Sep 2014 09:25:55 +0300	[thread overview]
Message-ID: <1409552778-2537-5-git-send-email-mikko.rapeli@iki.fi> (raw)
In-Reply-To: <1409552778-2537-1-git-send-email-mikko.rapeli@iki.fi>

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 5de5660..5391762 100644
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -1,4 +1,7 @@
 #!/bin/sh
+set -e
+set -u
+#set -x
 
 if [ $# -lt 1 ]
 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.0


  parent reply	other threads:[~2014-09-01  6:26 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1408660449-4011-1-git-send-email-mikko.rapeli@iki.fi>
2014-09-01  6:25 ` [RFC PATCH v2 00/27] Compile test and fixes for exported header files Mikko Rapeli
2014-09-01  6:25   ` [RFC PATCH v2 01/27] Compile test script " Mikko Rapeli
2014-09-01  6:25   ` [RFC PATCH v2 02/27] scripts/headers.sh: add verbose option to make calls if defined Mikko Rapeli
2014-09-01  6:25   ` [RFC PATCH v2 03/27] Makefile: propagate verbose options Mikko Rapeli
2014-09-01  6:25   ` Mikko Rapeli [this message]
2014-09-01  6:25   ` [RFC PATCH v2 05/27] drm.h: include stdlib.h in userspace Mikko Rapeli
2014-09-01  6:25   ` [RFC PATCH v2 06/27] drm_mode.h: include stdint.h and linux/types.h " Mikko Rapeli
2014-09-01  6:25   ` [RFC PATCH v2 07/27] exynos_drm.h: include stdint.h " Mikko Rapeli
2014-09-01  6:25   ` [RFC PATCH v2 08/27] nouveau_drm.h: " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 09/27] radeon_drm.h: " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 10/27] vmwgfx_drm.h: include drm/drm.h instead of drm.h " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 11/27] dm-log-userspace.h: include stdint.h " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 12/27] hsi_char.h: " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 13/27] ebtables.h: " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 14/27] cld.h: " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 15/27] rds.h: " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 16/27] sctp.h: " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 17/27] scsi_bsg_fc.h: " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 18/27] scsi_netlink.h: " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 19/27] scsi_netlink_fc.h: " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 20/27] hdspm.h: " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 21/27] gntalloc.h: " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 22/27] gntdev.h: " Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 23/27] r128_drm.h: include drm/drm.h Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 24/27] via_drm.h: include linux/types.h instead of non-existing via_drmclient.h Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 25/27] via_drm.h: hide struct via_file_private in userspace Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 26/27] savage_drm.h: include <drm/drm.h> Mikko Rapeli
2014-09-01  6:26   ` [RFC PATCH v2 27/27] sis_drm.h: hide sis_file_private in userspace Mikko Rapeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1409552778-2537-5-git-send-email-mikko.rapeli@iki.fi \
    --to=mikko.rapeli@iki.fi \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).