3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-17 09:29:30 +01:00

Interpreter: allow processing of empty result

This fixes .e.g.:

    <pragma-> !echo foo &{echo bar | { sed s/bar// }} baz

such that it produces the output "foo  baz" instead of no output at all.
This commit is contained in:
Pragmatic Software 2024-11-02 17:53:37 -07:00
parent f680439d47
commit af2d9844b8
No known key found for this signature in database
GPG Key ID: CC916B6E3C84ECCE
6 changed files with 16 additions and 14 deletions

View File

@ -224,6 +224,7 @@ sub interpreter($self, $context) {
);
# return no output since it will be handled by process manager
$context->{'skip-handle-result'} = 1;
return '';
} else {
# execute this command normally

View File

@ -79,9 +79,9 @@ sub execute($self, $context) {
# launch the `vm-client` applet
$self->{pbot}->{applets}->execute_applet($context);
# return empty string since the applet process reader will
# return undef since the applet process reader will
# pass the output along to the result handler
return '';
return undef;
}
1;

View File

@ -453,8 +453,7 @@ sub handle_action($self, $context, $action) {
my ($lang, $code) = ($1, $2);
$context->{lang} = $lang;
$context->{code} = $code;
$self->{pbot}->{factoids}->{code}->execute($context);
return '';
return $self->{pbot}->{factoids}->{code}->execute($context);
}
return $action if $context->{special} eq 'code-factoid';

View File

@ -230,7 +230,6 @@ sub process_line($self, $from, $nick, $user, $host, $text, $tags = '', $is_comma
# interpret all parsed commands
foreach $command (@commands) {
# check if user is ignored
# the `login` command gets a pass on the ignore filter
if ($command !~ /^login / and $self->{pbot}->{ignorelist}->is_ignored($from, "$nick!$user\@$host")) {
@ -578,9 +577,6 @@ sub interpret($self, $context) {
# sends final command output to appropriate queues.
# use context result if no result argument given.
sub handle_result($self, $context, $result = $context->{result}) {
# ensure we have a command result to work with
return if not defined $result or not length $result;
# preservation of consecutive whitespace is disabled by default
$context->{preserve_whitespace} //= 0;
@ -591,7 +587,13 @@ sub handle_result($self, $context, $result = $context->{result}) {
$Data::Dumper::Indent = 2;
$self->{pbot}->{logger}->log("Interpreter::handle_result [$result]\n");
$self->{pbot}->{logger}->log(Dumper $context);
$Data::Dumper::Sortkeys = 1;
}
# ensure we have a command result to work with
if (!defined $result || $context->{'skip-handle-result'}) {
$self->{pbot}->{logger}->log("Skipping handle_result\n");
delete $context->{'skip-handle-result'};
return;
}
# strip and store /command prefixes
@ -1228,7 +1230,7 @@ sub split_line($self, $line, %opts) {
}
}
$ch = $chars[$i++];
$ch = $chars[$i++];
$spaces = 0 if $ch ne ' ';

View File

@ -135,8 +135,8 @@ sub execute_process($self, $context, $subref, $timeout = undef, $reader_subref =
$self->{pbot}->{select_handler}->add_reader($reader, sub { $self->process_pipe_reader($context->{pid}, @_) });
}
# return empty string since reader will handle the output when child is finished
return '';
# return undef since reader will handle the output when child is finished
return undef;
}
}

View File

@ -25,8 +25,8 @@ use PBot::Imports;
# These are set by the /misc/update_version script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 4820,
BUILD_DATE => "2024-10-31",
BUILD_REVISION => 4821,
BUILD_DATE => "2024-11-02",
};
sub initialize {}