thewml / website-meta-language

An old offline HTML preprocessor (which can be used for static site generation), written in Perl and C that is still maintained for legacy reasons, but probably not recommended for new sites.
https://www.shlomifish.org/open-source/projects/website-meta-language/
GNU General Public License v2.0
14 stars 8 forks source link

Using Prolog filters bails out with »sh: 1: Syntax error: "(" unexpected« #12

Closed xtaran closed 5 years ago

xtaran commented 5 years ago

In my setup, wml called by wmk (after having fixed #10 and #11) bails out as follows once per skipped (!) file:

→ wmk
sh: 1: Syntax error: "(" unexpected
/usr/bin/wml -n '-o(ALL-LANG_*)+LANG_EN:geekcode.en.html' '-o(ALL-LANG_*)+LANG_DE:geekcode.de.html' geekcode.wml  (skipped)

My .wmlrc:

-o (ALL-LANG_*)+LANG_EN:%BASE.en.html -o (ALL-LANG_*)+LANG_DE:%BASE.de.html
-I `pwd`/../wml
-i template.wml
-W 7,"-F imgsize"
-W 7,"-F center"
-W 7,"-F space"
-W 7,"-F quotes"
# 1+8 = 9 (see mp4h(1))
-W 2,"-X 9"
#-E tidy
-P ~/bin/markdown-if-md.sh
-E ~/bin/tidy-no-writeback.pl

My .wmkrc:

-o (ALL-LANG_*)+LANG_EN:%BASE.en.html -o (ALL-LANG_*)+LANG_DE:%BASE.de.html
-A *.wml
-A *.md

The cause is this call of system() in wml_include/TheWML/Frontends/Wml/Runner.pm, lines 260-262:

            my $rc = system(
"$p <$self->temp_fn >$self->temp_fn.f && mv $self->temp_fn.f $self->temp_fn 2>/dev/null"
            );

$self is evaluated, but the method calls afterwards are not, causing a call like program <TheWML::Frontends::Wml::Runner=HASH(0x558f07307458)->temp_fn >TheWML::Frontends::Wml::Runner=HASH(0x558f07307458)->temp_fn.f && mv TheWML::Frontends::Wml::Runner=HASH(0x558f07307458)->temp_fn.f TheWML::Frontends::Wml::Runner=HASH(0x558f07307458)->temp_fn 2>/dev/null.

Here's my patch for this, proper pull request will follow:

--- a/src/wml_include/TheWML/Backends/IPP/Main.pm
+++ b/src/wml_include/TheWML/Backends/IPP/Main.pm
@@ -258,7 +258,7 @@
         foreach my $p (@$opt_P)
         {
             my $rc = system(
-"$p <$self->temp_fn >$self->temp_fn.f && mv $self->temp_fn.f $self->temp_fn 2>/dev/null"
+"$p <".$self->temp_fn." >".$self->temp_fn.f." && mv ".$self->temp_fn.f." ".$self->temp_fn." 2>/dev/null"
             );
             $self->error("Prolog Filter `$p' failed") if ( $rc != 0 );
         }

Might need some polish to get rid of the even longer line.