From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A939B43252; Tue, 31 Oct 2023 16:55:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A2741402D9; Tue, 31 Oct 2023 16:55:21 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 34A8240284 for ; Tue, 31 Oct 2023 16:55:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698767719; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yvyk75l3eQrw/9XJo8uOx0Lo1rwbNbLznhiqePknzh0=; b=aZ0EQFHGRhwdWLBcRUFslmcB3cR2HLF7PKKM4Qt6wYWu62aEREY51sy468aTPauFYalvsP zWJ2hOUhBFidSEsGjQYtnGXs07kiZQQd1immDzWG8WG/z7HCgAOXZIS1oJtfvRvOP7THl1 p+hTTt6K0H9p2dE0QIPhsfY1QbnU+y0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-hZ4q24c6OSCocrIo5ZcEFw-1; Tue, 31 Oct 2023 11:54:38 -0400 X-MC-Unique: hZ4q24c6OSCocrIo5ZcEFw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C993C881E2E for ; Tue, 31 Oct 2023 15:54:06 +0000 (UTC) Received: from RHTPC1VM0NT (unknown [10.22.9.87]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B26240C6EBC; Tue, 31 Oct 2023 15:54:06 +0000 (UTC) From: Aaron Conole To: Michael Santana Cc: Dumitru Ceara , David Marchand , Ilya Maximets , ci@dpdk.org Subject: Re: [RFC 1/2] pw_mon: improve command line options References: <20231027130609.3035396-1-aconole@redhat.com> Date: Tue, 31 Oct 2023 11:54:06 -0400 In-Reply-To: (Michael Santana's message of "Tue, 31 Oct 2023 10:45:09 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: ci@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK CI discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ci-bounces@dpdk.org Michael Santana writes: > On Fri, Oct 27, 2023 at 9:06=E2=80=AFAM Aaron Conole = wrote: >> >> In the future, we'll use this to add support for passing opts into some = parts >> of pw_mon. >> >> Signed-off-by: Aaron Conole >> --- >> pw_mon | 53 +++++++++++++++++++++++++++++++++++++++-------------- >> 1 file changed, 39 insertions(+), 14 deletions(-) >> >> diff --git a/pw_mon b/pw_mon >> index 28feb8b..01bdd25 100755 >> --- a/pw_mon >> +++ b/pw_mon >> @@ -21,34 +21,59 @@ >> >> [ -f "${HOME}/.pwmon-rc" ] && source "${HOME}/.pwmon-rc" >> >> -if [ "$1" !=3D "" ]; then >> - pw_project=3D"$1" >> - shift >> +if [ "$1" !=3D "" ]; then > nitpick: there is an extra white space between "" and ] >> + if ! echo "$1" | grep -E ^-- >/dev/null 2>&1; then > I am trying to understand what you are trying to accomplish with these > if statements and the while loop. Couldnt you just move everything > into the while loop so you dont have to repeat the checks? I mean, you > will probably still have to use an OR || to check both conditions, > with and without the "--" at the begining. Maybe you could use some > sort of regex to make the "--" optional and then maybe you could > combine both checks into a single check and make it much easier Not exactly. We need to keep some compatibility, so if the first argument doesn't start with "--" then we will treat it like a legacy parameter. > But just to double check, you are trying to parse both > "--pw-instance=3Dmyinstance" and "pw-instance=3Dmyinstance". Correct? > That's the whole goal of this patch? No. Original functionality would be like: $ ./pw_mon project instance credentials New functionality accepts this, and also will accept: $ ./pw_mon --pw-project=3Dproject --pw-instance=3Dinstance ... > The lack of strings around ^-- make me really unseasy, this also > applies to the sed line.=20 Why? You think it needs to be escaped? > Also, with grep you can tell it to not dump > any output/error. see -s and -q options. These apply to the other grep > commands in the script as well Okay - I'll use -q and -s instead of redirections. >> + pw_project=3D"$1" >> + shift >> + fi >> fi >> >> if [ "$1" !=3D "" ]; then >> - pw_instance=3D"$1" >> - shift >> -fi >> - >> -if [ "X$pw_instance" =3D=3D "X" -o "X$pw_project" =3D=3D "X" ]; then >> - echo "ERROR: Patchwork instance and project are unset." >> - echo "Please setup ${HOME}/.pwmon-rc and set pw_project " >> - echo "(or pass it as an argument)." >> - echo "Also either setup pw_instance or pass it as an argument." >> - exit 1 >> + if ! echo "$1" | grep -E ^-- >/dev/null 2>&1; then >> + pw_instance=3D"$1" >> + shift >> + fi >> fi >> >> userpw=3D"" >> >> if [ "$1" !=3D "" ]; then >> - pw_credential=3D"$1" >> + if ! echo "$1" | grep -E ^-- >/dev/null 2>&1; then > why is this not inside the while loop? the use of -- forbidden for > credentials via the cli? No - ^-- means only match -- at the beginning of the line. But there's a good catch here that we don't actually preserve the ability to set pw_credentials via a new style option. >> + pw_credential=3D"$1" >> + shift >> + fi >> fi >> >> + >> +while [ "$1" !=3D "" ]; do > Im guessing the whole point of this patch was to add this while loop >> + if echo "$1" | grep -E ^--pw-project=3D >/dev/null 2>&1; then >> + pw_project=3D$(echo "$1" | sed s/--pw-project=3D//) >> + shift >> + elif echo "$1" | grep -E ^--pw-instance=3D >/dev/null 2>&1; then >> + pw_instance=3D$(echo "$1" | sed s/--pw-instance=3D//) >> + shift >> + elif echo "$1" | grep -E ^--help >/dev/null 2>&1; then >> + echo "pw_mon script" >> + echo "$0 [proj|--pw-project=3D] [instance|--pw-instance= =3D> + echo "Options:" >> + echo " --add-filter-recheck=3Dfilter Adds a filter to flag = that a recheck needs to be done" >> + echo "" >> + exit 0 >> + fi >> +done >> + >> if [ "X$pw_credential" !=3D "X" ]; then >> userpw=3D"-u \"${pw_credential}\"" >> fi >> >> +if [ "X$pw_instance" =3D=3D "X" -o "X$pw_project" =3D=3D "X" ]; then >> + echo "ERROR: Patchwork instance and project are unset." >> + echo "Please setup ${HOME}/.pwmon-rc and set pw_project " >> + echo "(or pass it as an argument)." >> + echo "Also either setup pw_instance or pass it as an argument." >> + exit 1 >> +fi >> + >> source $(dirname $0)/series_db_lib.sh >> >> function emit_series() { >> -- >> 2.41.0 >>