From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ECBC9A0583; Thu, 19 Mar 2020 19:20:28 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C85721C05C; Thu, 19 Mar 2020 19:20:27 +0100 (CET) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id 98AB325D9 for ; Thu, 19 Mar 2020 19:20:26 +0100 (CET) Received: by mail-pl1-f195.google.com with SMTP id h11so1400618plk.7 for ; Thu, 19 Mar 2020 11:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1+LCJ+KDd/YyrtF8U6Z6gJDvcsyfypcp+HmczQ7yXJA=; b=d2RoKV11q+f8Vv3N4vwQOfrY9Jo4TKfecR16ZIejoOzubfW1f9PTFScnCf2dZ/LlWw Cf9v/f2GA482yON/c5tpbdPZwG8zFRK0ySUjSzf0yp8fkO3oMIS4/6IE+HhEXmsfIWGf J3HrPMNerZVRByCex2eyfgmnO/+Ix4H/XLqw23OzU14Fxa4dKhpLX+dK7Yu4JJPezeOI r0z9xgzEwvfZzB0L99VRMuFKugYEAxbIYPzBWBU9lOhrnlFe5czMbhmf66/oA0vnJNYI 5HRZxclmFzdSkLj8cAmEgvG0A5AjWQ2KnI5jdUT+gGC/mTh57MkpnYZ9EPd+jwynVt7K Ax1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1+LCJ+KDd/YyrtF8U6Z6gJDvcsyfypcp+HmczQ7yXJA=; b=DkyQ6mqqnlMvgCJqVvgNnYS+a+WimjiN5yuEtJ1UPD60EBuB71LQ6PVbeBzUEm7WHw GXenZqiJ2uzN4vu6of8f30GefbZqBft5TC53E0A9c9RbaNIcBBa7lvqnFAmW4z4o/XX+ 7lyRwUn4tbA0mJhMT31EsLcxzCSy2ACy6TOFucOHdLE8XbrVq7PSb8zEabtPq/n2yvSQ SdfkGY/97/P9frrF7qZi+4w49vRPX3S2548mAkx+4UctN1GygjqO54P+igyWuz0SIpMh fQV/TxlPyPE6GMCuOTTUuCc/2n/F0ZLLZYmfO8rOFF6iYBgSkq0BtpvGi7dLm451sLw/ QROg== X-Gm-Message-State: ANhLgQ0cFE6vYaCSASTZCopkDfmxcClAmEioqefdn34ElG6+SOzNjrz9 bl2//kOdhHnmtkWaPPfF/v/GWQ== X-Google-Smtp-Source: ADFU+vsfTtszAEdM9h2i+BmmZexI+X4W44PoGFDQMDf2PssUmNcK15X+fMPQPW/LEpnComuY4WK3iw== X-Received: by 2002:a17:902:8a89:: with SMTP id p9mr4726555plo.286.1584642025489; Thu, 19 Mar 2020 11:20:25 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 26sm2947517pgs.85.2020.03.19.11.20.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2020 11:20:25 -0700 (PDT) Date: Thu, 19 Mar 2020 11:20:15 -0700 From: Stephen Hemminger To: Sarosh Arif Cc: dev@dpdk.org, stable@dpdk.org Message-ID: <20200319112015.6e7d5f84@hermes.lan> In-Reply-To: <20200319174423.28378-1-sarosh.arif@emumba.com> References: <20200319174423.28378-1-sarosh.arif@emumba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v1] usertools/dpdk-setup.sh: fix dpdk-setup's behaviour on non-alphanumeric inputs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, 19 Mar 2020 22:44:23 +0500 Sarosh Arif wrote: > Bugzilla ID: 419 > Cc: stable@dpdk.org > Signed-off-by: Sarosh Arif > --- > usertools/dpdk-setup.sh | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/usertools/dpdk-setup.sh b/usertools/dpdk-setup.sh > index e5bbe9fee..bdacf5256 100755 > --- a/usertools/dpdk-setup.sh > +++ b/usertools/dpdk-setup.sh > @@ -595,8 +595,14 @@ while [ "$QUIT" == "0" ]; do > echo -n "Option: " > read our_entry > echo "" > - ${OPTIONS[our_entry]} ${our_entry} > - > + echo $our_entry | grep "^[0-9]*$" > /dev/null > + > + if [ "$?" -eq 0 ] ; then > + ${OPTIONS[our_entry]} ${our_entry} > + else > + echo "Wrong input format" > + fi > + > if [ "$QUIT" == "0" ] ; then > echo > echo -n "Press enter to continue ..."; read Why not do it with regex (abi check has similar code) and use the nice format. Also handle EOF diff --git a/usertools/dpdk-setup.sh b/usertools/dpdk-setup.sh index e5bbe9feec49..f594769a4ef1 100755 --- a/usertools/dpdk-setup.sh +++ b/usertools/dpdk-setup.sh @@ -592,10 +592,16 @@ while [ "$QUIT" == "0" ]; do echo "[$OPTION_NUM] Exit Script" OPTIONS[$OPTION_NUM]="quit" echo "" - echo -n "Option: " - read our_entry + read -p "Option: " our_entry + [ $? -eq 0 ] || exit 0 + echo "" - ${OPTIONS[our_entry]} ${our_entry} + numeric="^[[:digit:]]+$" + if [[ "$our_entry" =~ $numeric ]]; then + ${OPTIONS[our_entry]} ${our_entry} + else + echo "Please enter a numeric value" + fi if [ "$QUIT" == "0" ] ; then echo --