From 05cf63e00c672b54217c822985dd1b4fa726807b Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 23 Mar 2023 08:56:58 -0700 Subject: [PATCH] Interpreter: fix $0 in commands that use &{subs} --- lib/PBot/Core/Interpreter.pm | 7 +++++++ lib/PBot/VERSION.pm | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/PBot/Core/Interpreter.pm b/lib/PBot/Core/Interpreter.pm index 1be22576..f4850fa9 100644 --- a/lib/PBot/Core/Interpreter.pm +++ b/lib/PBot/Core/Interpreter.pm @@ -368,6 +368,13 @@ sub interpret { # add it to the list of substituted commands push @{$context->{subcmd}}, "$keyword $arguments"; + # FIXME: quick-and-dirty hack to fix $0. + # Without this hack `pet &{echo dog}` will output `You echo + # the dog` instead of `You pet the dog`. + if (not defined $context->{root_keyword}) { + $context->{root_keyword} = $keyword; + } + # trim surrounding whitespace $command =~ s/^\s+|\s+$//g; diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index c0a849e2..f45ec02c 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,8 +25,8 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4632, - BUILD_DATE => "2023-03-19", + BUILD_REVISION => 4633, + BUILD_DATE => "2023-03-23", }; sub initialize {}