Modified:
trunk/Changes
trunk/Makefile.PL
trunk/bin/pirl
trunk/lib/Shell/Perl.pm
Log:
local editor variables; more general history methods; document quit
Modified: trunk/Changes
==============================================================================
--- trunk/Changes (original)
+++ trunk/Changes Mon Mar 3 11:49:26 2008
@@ -1,5 +1,12 @@
Revision history for Perl extension Shell::Perl.
+0.016 Mar 3, 2008
+ - quit is now a method
+ - history is now persistent across sections
+ (should work with T::RL::Gnu and T::RL::Perl)
+ - new dependencies: File::HomeDir, Path::Class,
+ and File::Slurp
+
0.0015 Jul 27, 2007
- fixed 'quit'
- the first of the Expect tests: t/20expect_quit.t
Modified: trunk/Makefile.PL
==============================================================================
--- trunk/Makefile.PL (original)
+++ trunk/Makefile.PL Mon Mar 3 11:49:26 2008
@@ -13,6 +13,10 @@
Class::Accessor => 0,
Getopt::Long => 0,
+ File::Slurp => 0,
+ File::HomeDir => 0,
+ Path::Class => 0,
+
Test::More => 0,
},
Modified: trunk/bin/pirl
==============================================================================
--- trunk/bin/pirl (original)
+++ trunk/bin/pirl Mon Mar 3 11:49:26 2008
@@ -70,7 +70,7 @@
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2007 by Adriano R. Ferreira
+Copyright (C) 2007, 2008 by Adriano R. Ferreira
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
Modified: trunk/lib/Shell/Perl.pm
==============================================================================
--- trunk/lib/Shell/Perl.pm (original)
+++ trunk/lib/Shell/Perl.pm Mon Mar 3 11:49:26 2008
@@ -228,24 +228,42 @@
}
sub _history_file { # XXX
- return glob '~/.pirl-history'; # FIXME
- }
+ require Path::Class;
+ require File::HomeDir;
+ return Path::Class::file( File::HomeDir->my_home, '.pirl-history' )->stringify;
+}
sub _read_history { # XXX belongs to Shell::Perl::ReadLine
my $term = shift;
+ my $h = _history_file;
+ #warn "read history from $h\n"; # XXX
if ( $term->Features->{readHistory} ) {
- $term->ReadHistory( _history_file );
+ $term->ReadHistory( $h );
+ } elsif ( $term->Features->{setHistory} ) {
+ if ( -e $h ) {
+ require File::Slurp;
+ my @h = File::Slurp::read_file( $h );
+ chomp @h;
+ $term->SetHistory( @h );
+ }
+ } else {
+ # warn "Your ReadLine doesn't support setHistory\n";
}
-# if ( !$self->term->Features->{readHistory} ) {
-# print "Your Readline doesn't support getHistory\n";
-# return;
-# }
+
}
sub _write_history { # XXX belongs to Shell::Perl::ReadLine
my $term = shift;
+ my $h = _history_file;
+ #warn "write history to $h\n"; # XXX
if ( $term->Features->{writeHistory} ) {
- $term->WriteHistory( _history_file );
+ $term->WriteHistory( $h );
+ } elsif ( $term->Features->{getHistory} ) {
+ require File::Slurp;
+ my @h = map { "$_\n" } $term->GetHistory;
+ File::Slurp::write_file( $h, @h );
+ } else {
+ # warn "Your ReadLine doesn't support getHistory\n";
}
}
@@ -636,6 +654,24 @@
executable name and context. For example,
"pirl @>", "pirl $>", and "pirl >".
+=item B<quit>
+
+ $sh->quit;
+
+This method is invoked when these commands and
+statements are parsed by the REPL:
+
+ :q
+ :quit
+ :x
+ :exit
+ quit
+ exit
+
+It runs the shutdown procedures for a smooth
+termination of the shell. For example, it
+saves the terminal history file.
+
=back
=head1 GORY DETAILS
@@ -738,9 +774,16 @@
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2007 by Adriano R. Ferreira
+Copyright (C) 2007, 2008 by Adriano R. Ferreira
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
+
+# Local variables:
+# c-indentation-style: bsd
+# c-basic-offset: 4
+# indent-tabs-mode: nil
+# End:
+# vim: expandtab shiftwidth=4: