From b2273d32fb228351e6f33c595682676cb1ef1c04 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 8 Dec 2017 20:26:08 -0800 Subject: [PATCH] Extract nested command substitutions and pipes --- PBot/Interpreter.pm | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/PBot/Interpreter.pm b/PBot/Interpreter.pm index 7aac89b9..23767607 100644 --- a/PBot/Interpreter.pm +++ b/PBot/Interpreter.pm @@ -166,7 +166,6 @@ sub process_line { last if not defined $extracted; $extracted =~ s/^\{\s*//; $extracted =~ s/\s*\}$//; - $self->{pbot}->{logger}->log("Extracted embedded command [$extracted]\n"); push @commands, $extracted; $embedded = 1; } @@ -251,23 +250,32 @@ sub interpret { } # parse out a substituted command - if (defined $arguments && $arguments =~ s/(?{subcmd}}, "$keyword $arguments"; - $stuff->{command} = $command; - my $result = $self->interpret($stuff); - $stuff->{result} = $result; - return $result; + if (defined $arguments && $arguments =~ m/(?{subcmd}}, "$keyword $arguments"; + $stuff->{command} = $command; + $stuff->{result} = $self->interpret($stuff); + return $stuff->{result}; + } } # unescape any escaped substituted commands $arguments =~ s/\\&\{/&{/g if defined $arguments; - # parse out a pipe unless escaped + # parse out a pipe if (defined $arguments && $arguments =~ m/(?{pbot}->{logger}->log("piping: [$args][$pipe][$rest]\n");