Skip to contentSkip to conversation

configure: process arguments not starting with dash

PATCH Applied Nico Boehr 2 participants 2 messages Sep 13, 2024 – Oct 10, 2024

Subsystems (2)
lore
Share & tools
lore

Nico Boehr

author
#0 lore raw

PATCH 1/1 configure: process arguments not starting with dash

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.

---
 configure | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
configure +4 -1
index 27ae9cc89657..85a2358ca20b 100755
@@ -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#*=}"
Signature · 1 line
2.46.0
Applied
#1 lore raw
Quoted 28 lines · Nico Boehr

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.

Quoted 8 lines

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.

---
  configure | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)

Thanks, applied!

Thomas