From patchwork Thu Oct 20 15:46:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 78535 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp850909qge; Thu, 20 Oct 2016 08:46:33 -0700 (PDT) X-Received: by 10.99.114.29 with SMTP id n29mr1967611pgc.7.1476978393471; Thu, 20 Oct 2016 08:46:33 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id g23si42139403pgn.73.2016.10.20.08.46.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Oct 2016 08:46:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0BB911A1E86; Thu, 20 Oct 2016 08:46:33 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-qt0-x229.google.com (mail-qt0-x229.google.com [IPv6:2607:f8b0:400d:c0d::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 76EF41A1E34 for ; Thu, 20 Oct 2016 08:46:30 -0700 (PDT) Received: by mail-qt0-x229.google.com with SMTP id q7so60057690qtq.1 for ; Thu, 20 Oct 2016 08:46:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BzObgkSle4IC4ahH8ToBSgocB3C2jPSV6fiduCNQ/6g=; b=I4PSTRAKKmOrlXUdAbVr/EkwrHKpZB1zeW4sBrBkPvRWLTUHHlJV9OltpnjyV6d0Zd v2nZBNhsYSCCTdlpLwVg8oxd89S5v4zS9WkSa9f8hAxy7Ai/zZyvXo1WOw6yuvKsH+8F pAaQ5ITeTMbYVxQ9EqvcSjv/BeuAUqdLpGr28= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BzObgkSle4IC4ahH8ToBSgocB3C2jPSV6fiduCNQ/6g=; b=UtAlWnMsxvrMpqiaCvusUDz7uQh5xb/AWPSzLxBvbGXJh+EXErhbxUd3uJmoDlCoB6 nb63L1TDGp2lE9T1pZhmuUZxythfC98oWLT1RKyB5TDYuGTe17HeG1gHSIwNT7ZGL+uF V77QrVuLfzToOlAUtg14Zo468jWxmJdik5oatACm2Hb4GDK9prd90/EnNfUNmvdHJuLv ZlOfwgeGxOh0eR8BDU+Z4/xzVeTKY30noU/NF5FtTSGuH/i922LgHZqllIvv37Xlt0FE ZLglTGGQts3G+7jdkXGy9C6FTXNluRd2ob7Jf5Fwfw0v+hibY6EsAohysyrNHQ1PdHKi sFdg== X-Gm-Message-State: AA6/9RmxEgIUyl1i/+7/vYYOjAcwfEQSzAg0ScbPD3FET7N04SnT7o4A/AMbDZvQ0bmjwUMX X-Received: by 10.28.193.1 with SMTP id r1mr849595wmf.11.1476978389264; Thu, 20 Oct 2016 08:46:29 -0700 (PDT) Received: from mohikan.eciton.net ([2a01:348:6:8735:e23f:49ff:fe6d:9d26]) by smtp.gmail.com with ESMTPSA id ce6sm79640115wjc.27.2016.10.20.08.46.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Oct 2016 08:46:28 -0700 (PDT) From: Leif Lindholm To: edk2-devel@lists.01.org Date: Thu, 20 Oct 2016 16:46:24 +0100 Message-Id: <20161020154625.31352-2-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161020154625.31352-1-leif.lindholm@linaro.org> References: <20161020154625.31352-1-leif.lindholm@linaro.org> Subject: [edk2] [PATCH 1/2] edksetup.sh: rework argument parsing and update usage information X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Rework the argument parsing logic to a more extensible traditional while/case setup to prepare for further additions. While doing that, align the Usage printout to look a bit more like the output of Edk2Setup.bat (and be more correct). And also stop passing around command line options to the BuildEnv script (which does not check them anyway). Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Leif Lindholm --- edksetup.sh | 65 +++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 28 deletions(-) -- 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/edksetup.sh b/edksetup.sh index 27c0994..7b54223 100755 --- a/edksetup.sh +++ b/edksetup.sh @@ -1,5 +1,6 @@ # # Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2016, Linaro Ltd. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -22,12 +23,21 @@ # Please reference edk2 user manual for more detail descriptions at https://github.com/tianocore-docs/Docs/raw/master/User_Docs/EDK_II_UserManual_0_7.pdf # +SCRIPTNAME="edksetup.sh" + function HelpMsg() { + echo "Usage: $SCRIPTNAME [Options]" + echo + echo "The system environment variable, WORKSPACE, is always set to the current" + echo "working directory." + echo + echo "Options: " + echo " --help, -h, -? Print this help screen and exit." + echo echo Please note: This script must be \'sourced\' so the environment can be changed. - echo ". edksetup.sh" - echo "source edksetup.sh" - return 1 + echo ". $SCRIPTNAME" + echo "source $SCRIPTNAME" } function SetWorkspace() @@ -71,10 +81,10 @@ function SetupEnv() { if [ -n "$EDK_TOOLS_PATH" ] then - . $EDK_TOOLS_PATH/BuildEnv $* + . $EDK_TOOLS_PATH/BuildEnv elif [ -f "$WORKSPACE/BaseTools/BuildEnv" ] then - . $WORKSPACE/BaseTools/BuildEnv $* + . $WORKSPACE/BaseTools/BuildEnv elif [ -n "$PACKAGES_PATH" ] then PATH_LIST=$PACKAGES_PATH @@ -84,7 +94,7 @@ function SetupEnv() if [ -f "$DIR/BaseTools/BuildEnv" ] then export EDK_TOOLS_PATH=$DIR/BaseTools - . $DIR/BaseTools/BuildEnv $* + . $DIR/BaseTools/BuildEnv break fi done @@ -99,32 +109,31 @@ function SetupEnv() function SourceEnv() { - if [ \ - "$1" = "-?" -o \ - "$1" = "-h" -o \ - "$1" = "--help" \ - ] - then - HelpMsg - else - SetWorkspace && - SetupEnv "$*" - fi + SetWorkspace && + SetupEnv } -if [ $# -gt 1 ] -then - HelpMsg -elif [ $# -eq 1 ] && [ "$1" != "BaseTools" ] -then - HelpMsg -fi +I=$# +while [ $I -gt 0 ] +do + case "$1" in + BaseTools) + # Ignore argument for backwards compatibility + shift + ;; + -?|-h|--help|*) + HelpMsg + break + ;; + esac + I=$(($I - 1)) +done -RETVAL=$? -if [ $RETVAL -ne 0 ] +if [ $I -gt 0 ] then - return $RETVAL + return 1 fi -SourceEnv "$*" +SourceEnv +return $?