public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v1] configure: process arguments not starting with dash
@ 2024-09-13  8:56 Nico Boehr
  2024-10-10  8:27 ` Thomas Huth
  0 siblings, 1 reply; 2+ messages in thread
From: Nico Boehr @ 2024-09-13  8:56 UTC (permalink / raw)
  To: frankja, imbrenda, thuth; +Cc: kvm, linux-s390

We have arguments in the configure script which take an additional
parameter, like --host-key-document. The syntax is as follows:

  --host-key-document=PARAMETER

We always expect an equals sign (=) after the argument name and the
parameter.

If the user omits '=' between the argument name and parameter, both
words will be interpreted as parameter-less arguments.

This on its own is not a problem, since the parameter would normally not
be a valid argument name and should hence lead to an error message.
However, this doesn't work currently.

The configure script stops parsing arguments when an argument starting
with something other than a dash is encountered. This means that
specifying arguments such as:

  --host-key-document /tmp/test --gen-se-header=/usr/bin/gen-se-header

Will actually lead to --gen-se-header being ignored. Note the space
instead of equals sign after --host-hey-document.

In addition, --host-key-document only verifies its parameter when it is
not empty so we will just continue as if no arguments were specified in
the case above.

This can be highly confusing, hence consume _all_ specified arguments,
even if they don't start with a dash. This will lead to an error in the
case above.

Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 configure | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 27ae9cc89657..85a2358ca20b 100755
--- a/configure
+++ b/configure
@@ -102,8 +102,11 @@ EOF
     exit 1
 }
 
-while [[ "$1" = -* ]]; do
+optno=1
+argc=$#
+while [[ $optno -le $argc ]]; do
     opt="$1"; shift
+    optno=$(( $optno + 1 ))
     arg=
     if [[ "$opt" = *=* ]]; then
 	arg="${opt#*=}"
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [kvm-unit-tests PATCH v1] configure: process arguments not starting with dash
  2024-09-13  8:56 [kvm-unit-tests PATCH v1] configure: process arguments not starting with dash Nico Boehr
@ 2024-10-10  8:27 ` Thomas Huth
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Huth @ 2024-10-10  8:27 UTC (permalink / raw)
  To: Nico Boehr, frankja, imbrenda; +Cc: kvm, linux-s390

On 13/09/2024 10.56, Nico Boehr wrote:
> We have arguments in the configure script which take an additional
> parameter, like --host-key-document. The syntax is as follows:
> 
>    --host-key-document=PARAMETER
> 
> We always expect an equals sign (=) after the argument name and the
> parameter.
> 
> If the user omits '=' between the argument name and parameter, both
> words will be interpreted as parameter-less arguments.
> 
> This on its own is not a problem, since the parameter would normally not
> be a valid argument name and should hence lead to an error message.
> However, this doesn't work currently.
> 
> The configure script stops parsing arguments when an argument starting
> with something other than a dash is encountered. This means that
> specifying arguments such as:
> 
>    --host-key-document /tmp/test --gen-se-header=/usr/bin/gen-se-header
> 
> Will actually lead to --gen-se-header being ignored. Note the space
> instead of equals sign after --host-hey-document.
> 
> In addition, --host-key-document only verifies its parameter when it is
> not empty so we will just continue as if no arguments were specified in
> the case above.
> 
> This can be highly confusing, hence consume _all_ specified arguments,
> even if they don't start with a dash. This will lead to an error in the
> case above.
> 
> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
> ---
>   configure | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)

Thanks, applied!

  Thomas


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-10  8:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-13  8:56 [kvm-unit-tests PATCH v1] configure: process arguments not starting with dash Nico Boehr
2024-10-10  8:27 ` Thomas Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox