[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Fix AT_ARG_OPTION_ARG handling of options with hyphens.
From: |
Nick Bowler |
Subject: |
[PATCH] Fix AT_ARG_OPTION_ARG handling of options with hyphens. |
Date: |
Sat, 15 Feb 2020 10:54:08 -0500 |
The manual says that given e.g., AT_ARG_OPTION_ARG([my-option],
[ --my-option=ARG]), the user can pass either --my-option=val
or --my-option val to the testsuite with equivalent results.
However, if the option name contains a hyphen, only the first
form actually works because the argument parser combines the
two arguments into --my_option=val which it immediately confuses
for an invalid variable assignment, for example:
% ./testsuite --my-option val
testsuite: error: invalid variable name: `--my_option'
* lib/autotest/general.m4 (_AT_ARG_OPTION): Set at_prev to untransformed
option name to fix argument parsing for options containing hyphens.
* tests/autotest.at (AT_ARG_OPTION_ARG): Ensure the two-argument form
for options containing hyphens is covered by the test suite.
---
lib/autotest/general.m4 | 2 +-
tests/autotest.at | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 5d89d0c06937..f58f111a7626 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -1712,7 +1712,7 @@ m4_divert_text([PARSE_ARGS],
[dnl Parse the options and args when necessary.
m4_ifvaln([$3],
[ AT_case )
- at_prev=--AT_first_option_tr
+ at_prev=--AT_first_option
;;
AT_case_arg )
at_arg_[]AT_first_option_tr=$at_optarg
diff --git a/tests/autotest.at b/tests/autotest.at
index 7734277f021f..405a05fa11c6 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -1358,7 +1358,8 @@ for args in \
'1 --fro=bar FROB=bar FROB_ARG=bar' \
'1 --frob=bar FROB=bar FROB_ARG=bar' \
'2 expected=' \
- '2 --opt-with-hyphen=baz expected=baz'
+ '2 --opt-with-hyphen=baz expected=baz' \
+ '2 --opt-with-hyphen baz expected=baz'
do
AT_CHECK([$CONFIG_SHELL ./micro-suite -x $args], [], [ignore])
done
--
2.24.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Fix AT_ARG_OPTION_ARG handling of options with hyphens.,
Nick Bowler <=