From c6c254da652ba18021fc341fa7a6c8f1c0cc0b57 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Sat, 1 Jan 2011 18:01:56 +0000 Subject: feature_tests/easy_exec: further futile efforts to make a /script exec that exposes all the Irssi exportables into the temp namespace. --- feature-tests/easy_exec.pl | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/feature-tests/easy_exec.pl b/feature-tests/easy_exec.pl index dbcd101..669a00b 100644 --- a/feature-tests/easy_exec.pl +++ b/feature-tests/easy_exec.pl @@ -2,7 +2,7 @@ use strict; use warnings; # export everything. -use Irssi (@Irssi::EXPORT_OK); +use Irssi; #(@Irssi::EXPORT_OK); use Irssi::Irc; use Irssi::TextUI; @@ -18,12 +18,27 @@ our %IRSSI = ( license => 'Public Domain', ); -Irssi::signal_add_first 'command script exec', \&better_exec; +#Irssi::signal_add_first 'command script exec', \&better_exec; +Irssi::command_bind('script exec', \&better_exec); sub better_exec { my ($args, $serv, $witem) = @_; - eval $args; - Irssi::signal_stop(); + # todo: handle permanent arg? + my $perm = 0; + print "Args: $args"; + if ($args =~ s/^\s*-permanent\s*(.*)$/$1/) { + $perm = 1; + } + print "Args now: $args"; + +# eval $args; + my $str = "//script exec " . + ($perm ? '-permanent' : '') + . 'use Irssi (@Irssi::EXPORT_OK); ' . $args; + print "Running: $str"; + +# Irssi::command($str); + Irssi::signal_continue($str, @_[1..$#_]); } sub Dump { -- cgit v1.2.3