]> git.draconx.ca Git - dxcommon.git/commitdiff
at-compat.at: Add patch to fix option parsing bug.
authorNick Bowler <nbowler@draconx.ca>
Sat, 23 Dec 2023 16:22:03 +0000 (11:22 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sat, 23 Dec 2023 16:22:03 +0000 (11:22 -0500)
This fixes a bug in AT_ARG_OPTION_ARG where the two-argument form
does not work if the option name contains a hyphen:

  % ./testsuite --my-option val
  testsuite: error: invalid variable name: `--my_option'

snippet/at-compat.at

index 01cfc886440b2e4a3d9c8f95ace19ebecfb2fe8c..6eb6d97042a6dcd5f4d5bbbeda055c206fc4550a 100644 (file)
@@ -7,14 +7,24 @@
 # This is free software: you are free to do what the fuck you want to.
 # There is NO WARRANTY, to the extent permitted by law.
 
-# In a shell function, redirections on : are not correctly handled
-# by Solaris /bin/sh.  See the following Autoconf patch for details:
+# In a shell function, redirections on : are not correctly handled by some
+# shells, including Solaris 10 /bin/sh.  Work around the problem using 'eval'.
+# See the following Autoconf patch description for further details:
 #
 #   https://lists.gnu.org/archive/html/autoconf-patches/2021-03/msg00000.html
 m4_define([AT_INIT],
   m4_bpatsubst(m4_dquote(m4_defn([AT_INIT])),
     [^\( *\)\(: >"\$at_stdout".*$\)], [\1eval '\2']))
 
+# Parsing of command-line options with arguments is busted in the two-argument
+# form if the option name contains a hyphen.  Apply a fix for this bug.  See
+# the following Autoconf patch description for further details:
+#
+#   https://lists.gnu.org/archive/html/autoconf-patches/2020-02/msg00000.html
+m4_define([_AT_ARG_OPTION],
+  m4_bpatsubst(m4_dquote(m4_defn([_AT_ARG_OPTION])),
+    [at_prev=--AT_first_option_tr], [at_prev=--AT_first_option]))
+
 # The computation of the elapsed time can crash the testsuite on DJGPP because
 # in this environment date +%s can return a string that starts with a 0, which
 # bash interprets as octal digits in arithmetic expansions.  With a working