Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752212AbbGCFEp (ORCPT ); Fri, 3 Jul 2015 01:04:45 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:36593 "EHLO e23smtp01.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751454AbbGCFEi (ORCPT ); Fri, 3 Jul 2015 01:04:38 -0400 X-Helo: d23dlp03.au.ibm.com X-MailFrom: sam.bobroff@au1.ibm.com X-RcptTo: linux-kernel@vger.kernel.org From: Sam Bobroff To: linux-kernel@vger.kernel.org Subject: [PATCH 1/1] merge_config.sh: exit on missing input files Date: Fri, 3 Jul 2015 15:03:37 +1000 Message-Id: <45b4e87ddc059dcddc36aa86649d2d52cc63da78.1435899816.git.sam.bobroff@au1.ibm.com> X-Mailer: git-send-email 2.1.4 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15070305-1618-0000-0000-00000254864E Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2561 Lines: 73 Add a check for the existence of input files and exit (with failure) if they are missing. Without this additional check, missing files produce error messages but still result in an output file being generated and a successful exit code. Signed-off-by: Sam Bobroff --- The current behaviour (of continuing to run with missing files) seems like a bug to me, and I've prepared the patch with what seems to be the safest fix: adding a test to explicitly check for file existence. Additionally, it seems like it might be a good idea (either with or without this patch) to add "set -e" to the script because this patch only handles missing files, not other errors (which will currently be ignored and return a successful exit code). Should I add this to the patch? This can be tested using the top level pseries_le_defconfig target and removing arch/powerpc/configs/le.config: $ rm arch/powerpc/configs/le.config $ make pseries_le_defconfig Unpatched behaviour: Using ../arch/powerpc/configs/pseries_defconfig as base Merging ../arch/powerpc/configs/le.config sed: can't read ../arch/powerpc/configs/le.config: No such file or directory cat: ../arch/powerpc/configs/le.config: No such file or directory # # merged configuration written to ./.config (needs make) # GEN ./Makefile scripts/kconfig/conf --olddefconfig Kconfig # # configuration written to .config # Patched behaviour: Using ../arch/powerpc/configs/pseries_defconfig as base Merging ../arch/powerpc/configs/le.config The merge file '../arch/powerpc/configs/le.config' does not exist. Exit. arch/powerpc/Makefile:289: recipe for target 'pseries_le_defconfig' failed scripts/kconfig/merge_config.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh index ec8e203..0d883b3 100755 --- a/scripts/kconfig/merge_config.sh +++ b/scripts/kconfig/merge_config.sh @@ -100,6 +100,10 @@ cat $INITFILE > $TMP_FILE # Merge files, printing warnings on overridden values for MERGE_FILE in $MERGE_LIST ; do echo "Merging $MERGE_FILE" + if [ ! -r "$MERGE_FILE" ]; then + echo "The merge file '$MERGE_FILE' does not exist. Exit." >&2 + exit 1 + fi CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE) for CFG in $CFG_LIST ; do -- 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/