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 3F309A0584 for ; Thu, 19 Mar 2020 19:20:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 24F651C06B; Thu, 19 Mar 2020 19:20:29 +0100 (CET) Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by dpdk.org (Postfix) with ESMTP id 9B2901C05C for ; Thu, 19 Mar 2020 19:20:26 +0100 (CET) Received: by mail-pj1-f66.google.com with SMTP id ng8so1369195pjb.2 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=ThgCsmjV7lAWfglPCs+7jdfE9+H6uUr5fZ7xqBVnrskX75gJSX4PYH9vvSCMLwlw/S G8ZbpIaJwMj2ecf53Jbu2PU1CBonpIV4oS8vHTdXjwJB9khF8rSSaeS3sO+0KQ3C6NzT qpQUENRSpQXar68hwpbhZtjnam8IFY8cmnTwMp2oeO/Ur2s37yprHDj+FGfTpQWSAy1Q M/KDCMz2Jzlyggjv/TcOOpw5CpnBnD/Om23SXJVfAPrmUpNij6KQ9MM4bjqK1pQNszat CwjPBPRS4E693/M0oiM5BZbeJjk6Wpkq6PMRDKNAHRiHowXezC5iQP215JDsF4HZYP8v LChw== X-Gm-Message-State: ANhLgQ3Fipfiq4aqGqgV4OVwY9bULYLKXU6LNupMklrWjKnz+hdpXmDH LnZ/nhjGP10yQHwTyYnQCPvUDQ== 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-stable] [dpdk-dev] [PATCH v1] usertools/dpdk-setup.sh: fix dpdk-setup's behaviour on non-alphanumeric inputs X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 --