Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

re.pl: Unable to find … in history

by daxim (Curate)
on Aug 22, 2019 at 10:49 UTC ( [id://11104850]=perlquestion: print w/replies, xml ) Need Help??

daxim has asked for the wisdom of the Perl Monks concerning the following question:

Repro:
  • run re.pl
  • execute !!1
Got: Unable to find !1 in history

Expect: 1

How do I make it stop? I have already tried without success:

repl.rc:
#!/usr/bin/env perl use 5.030; use lib 'lib'; use utf8; use strictures; use autodie qw(:all); use Moops; use Kavorka; use perl5i::2 -skip => [qw(Signatures)]; use Devel::REPL::Plugin::ReadLineHistory::WithoutExpansion; $_REPL->load_plugin(qw( Colors DataPrinter DumpHistory FindVariable History Interrupt LexEnv MultiLine::PPI OutputCache Packages Peek PPI Refresh ReadLineHistory::WithoutExpansion ShowClass Completion CompletionDriver::Globals CompletionDriver::INC CompletionDriver::Keywords CompletionDriver::LexEnv CompletionDriver::Methods CompletionDriver::Turtles )); $_REPL->term->Attribs->{history_quotes_inhibit_expansion} = 1; $_REPL->term->Attribs->{do_expand} = 0;

Replies are listed 'Best First'.
Re: re.pl: Unable to find … in history
by Corion (Patriarch) on Aug 22, 2019 at 11:01 UTC

    Looking through the source code of Devel::REPL::Plugin::History, it seems that Devel::REPL::Plugin::ReadLineHistory::WithoutExpansion simply fiddles the wrong bits (well, the ReadLine expansion of the underlying Term::ReadLine object). The source code in Devel::REPL::Plugin::History ignores all that and does the ! expansion in a hardcoded way:

    # Devel::REPL::Plugin::History around 'read' => sub { my $orig = shift; my ($self, @args) = @_; my $line = $self->$orig(@args); if (defined $line) { if ($line =~ m/^!(.*)$/) { my $call = $1; $line = $self->history_call($call); if (defined $line) { $self->print($line."\n"); } else { return "'Unable to find ${call} in history'"; } } if ($line =~ m/\S/) { $self->push_history($line); } } return $line; };

    Looking at the code more, prefixing !!1 by whitespace should work around the issue in the way you want...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11104850]
Approved by Marshall
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2025-03-27 17:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (70 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.