Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751742AbbBPXGV (ORCPT ); Mon, 16 Feb 2015 18:06:21 -0500 Received: from mail.kapsi.fi ([217.30.184.167]:58174 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751682AbbBPXGS (ORCPT ); Mon, 16 Feb 2015 18:06:18 -0500 From: Mikko Rapeli To: linux-kernel@vger.kernel.org Cc: Mikko Rapeli , Andrew Morton , Michal Marek , Javier Barrio Subject: [PATCH 03/45] headers_install.sh: enhance error handling Date: Tue, 17 Feb 2015 00:05:06 +0100 Message-Id: <1424127948-22484-4-git-send-email-mikko.rapeli@iki.fi> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1424127948-22484-1-git-send-email-mikko.rapeli@iki.fi> References: <1424127948-22484-1-git-send-email-mikko.rapeli@iki.fi> X-SA-Exim-Connect-IP: 2a02:8070:d1af:b300:219:d2ff:fe03:c7a9 X-SA-Exim-Mail-From: mikko.rapeli@iki.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1739 Lines: 56 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/