When texi2any is used as a driver for texi2dvi and variable definitions
are given on the command line like so,

    texi2any --pdf -D 'VARIABLE VALUE' document.texi

texi2any will pass --command='@set VARIABLE VALUE VALUE' to texi2dvi so
the variable will have a duplicate value. The attached example
demonstrates this. When running

    texi2any -D 'TheAnswer 42' document.texi

the Info file contains "The answer is 42." as expected. However, when
running

    texi2any --pdf -D 'TheAnswer 42' document.texi

then the PDF file will contain "The answer is 42 42." instead.

It seems that the problem is that texi2any tokenizes the argument given
to the -D option but then uses the original raw text /followed/ by the
extracted value, thus effectively duplicating the variable's value.

The attached patch is supposed to fix this problem.

\input texinfo
@settitle The Empty Manual

@titlepage
@title The Empty Manual
@end titlepage

@ifnottex
@node top
@top This is the Top node
@menu
* Overview::
@end menu
@end ifnottex

@contents

@node Overview
@chapter Overview

@ifset TheAnswer
The answer is @value{TheAnswer}.
@end ifset

@bye
commit 192719b6f237d9e2fbbc00ea6d9bce788ee46f5e
Author: Moritz Klammler <[email protected]>
Date:   Sun Sep 20 17:30:32 2020 +0200

    Fix duplication of VALUE when using texi2any --pdf -D 'VAR VALUE'.
    
    * tp/texi2any.pl (makeinfo_help): Fix accidental duplication of
    variable value passed via texi2any's -D option to texi2dvi.

diff --git a/ChangeLog b/ChangeLog
index d42c29982..764ef0d5a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-09-20  Moritz Klammler  <[email protected]>
+
+	* tp/texi2any.pl (makeinfo_help): Fix accidental duplication of
+	variable value passed via texi2any's -D option to texi2dvi.
+
 2020-09-20  Gavin Smith  <[email protected]>
 
 	* doc/texinfo.texi (Headings Introduced): Remove text that 
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index f6693eae3..00f31702c 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -863,7 +863,7 @@ There is NO WARRANTY, to the extent permitted by law.\n"), "2017";
       push @texi2dvi_args, "--command=\@set $var 1";
     } else {
       $parser_default_options->{'values'}->{$field[0]} = $field[1];
-      push @texi2dvi_args, "--command=\@set $var $field[1]";
+      push @texi2dvi_args, "--command=\@set $field[0] $field[1]";
     }
  },
  'U=s' => sub {

Attachment: 0x8AE0FE4977592DF7.asc
Description: application/pgp-keys

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to