From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 1FB965A004F for ; Thu, 08 Aug 2024 06:02:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723089758; 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=kOSIaqlQJrcHaArtY2tqVorO5gfQ+EKF21XOO4s0NAE=; b=Wnj3SymrL//R4pJKk0CMoLhas0mLL3DjTKWzErQqJ8pl4DBdnymDUW3R2/osnAQSON3dez 09N+e7ocgRENnrVaZoLHpuMjKDILPV6lORDGi98MLyKE89c9vbZxJpQiS1IXTAdT9VrL17 0YPrL6aQVD2klTQ+A8JSrPzdmU5JRu8= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-299-ZPUepsKjNVeZZOaEhKgslg-1; Thu, 08 Aug 2024 00:02:34 -0400 X-MC-Unique: ZPUepsKjNVeZZOaEhKgslg-1 Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-7a2d4261a48so502780a12.0 for ; Wed, 07 Aug 2024 21:02:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723089753; x=1723694553; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=kOSIaqlQJrcHaArtY2tqVorO5gfQ+EKF21XOO4s0NAE=; b=HjBMPfNJantLvW02ga53jJLVjrgTe5djfug8J9HaPpeG0S0rYiC6mAalU/9wV2Y7Be ljEW/qugPjxVVBq+G00IVMVIb7D5BodaIVcQhsA5x8WZjBOgE2J9EeYiSOelhZ4uPM6p 6XW1M6425uQQdr/sBCfs+cSYa2rDTjJc48u3B/x0sdZp1ZZf4uCDd9/BEDG0rKPwe2aw tFL4oWNH+YyIoor58KUdxtaleZKIXqkN4o1no4TuqTgkZK0Sc5O+cN5ZKHelCfT39V3O kSN5CweHQ1fjCZyx4Z73SM0UjTv6UjLORpIq5wXy3PpdbZSMTTQ7Rc4X6sRyb69JHidK HEfw== X-Gm-Message-State: AOJu0YyKLyGfU4OvmZ1f29UtzZAWCbaQPlgrr+lieGuTTWhVZ9jlucCq 7skxE9m3Tm5sNrUNoSoqn36bWqLObU+5S++JLHCpTIl76idkjZB5CT7iSqI4dZnTsMPRQu6yeEy 3SMaeuXBksZAw1GZlBWTEK5WtijEMsn4xY7DS3vSg4PH/wJ90mA== X-Received: by 2002:a05:6a21:8188:b0:1be:c262:9c0d with SMTP id adf61e73a8af0-1c6fcf9cc62mr512676637.44.1723089753064; Wed, 07 Aug 2024 21:02:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAeg1EAhUNCpQzegmhRPDcFGl/s88YLS9R5e0tNfXW4zSfGiQBIbzK7p+KTTY0NFuJYkru5w== X-Received: by 2002:a05:6a21:8188:b0:1be:c262:9c0d with SMTP id adf61e73a8af0-1c6fcf9cc62mr512659637.44.1723089752649; Wed, 07 Aug 2024 21:02:32 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d1b3ab3afcsm2427721a91.16.2024.08.07.21.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 21:02:31 -0700 (PDT) Date: Thu, 8 Aug 2024 06:02:28 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2] conf: Stop parsing options at first non-option argument Message-ID: <20240808060228.03a33799@elisabeth> In-Reply-To: References: <20240807112840.2113074-1-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: ZPFFFDGUE7DZ2XV3TCPPORCAJ6C3QMVX X-Message-ID-Hash: ZPFFFDGUE7DZ2XV3TCPPORCAJ6C3QMVX X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Paul Holzinger X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, 8 Aug 2024 10:57:24 +1000 David Gibson wrote: > On Wed, Aug 07, 2024 at 01:28:40PM +0200, Stefano Brivio wrote: > > Given that pasta supports specifying a command to be executed on the > > command line, even without the usual -- separator as long as there's > > no ambiguity, we shouldn't eat up options that are not meant for us. > > > > Paul reports, for instance, that with: > > > > pasta --config-net ip -6 route > > > > -6 is taken by pasta to mean --ipv6-only, and we execute 'ip route'. > > That's because getopt_long(), by default, shuffles the argument list > > to shift non-option arguments at the end. > > > > Avoid that by adding '-' at the beginning of 'optstring', and mark the > > position of the first non-option argument (getopt_long() will now > > return the character code 1 once we hit it), so that we can use that > > as command to run, or as PID for the target namespace. > > > > Reported-by: Paul Holzinger > > Signed-off-by: Stefano Brivio > > Eh... I'm kind of ambivalent about the idea. I tend to think that > accepting options in any position is generally expected behaviour, and > anything programmatically adding commands to pasta should routinely > insert a "--" (that's certainly what I do in testing code). Sure, on the other hand it's convenient when you're quickly trying out ip -6 route show, or some command where "--" would add 10% of typing or so. > But, that's not a particularly strong opinion, so whatever. > > The implementation looks more complex than necessary, though. AFAICT > if you just add a '+' to the front of the optstring it will do exactly > what you want without having to juggle the first_nonopt and other > variables. Oops, that's actually the first approach I considered, but I didn't see any guarantee that optind would assume the expected value after the loop. However, it does... sending v3. -- Stefano