#!/usr/bin/perl # collect a line of input, and send it to plod use POSIX; $PLOD = $ENV{HOME}."/bin/plod"; $PAGER = ($ENV{PAGER} || "/usr/bin/less"); $PROMPT = "plodshell> "; select STDOUT; $| = 1; MAIN: { $SIG{'INT'} = 'sig_end_entry'; umask 0077; system ($PLOD, "plodshell start"); print $PROMPT; while (<>) { chomp; if ($_ eq "^") { print "Entering interactive mode (exit with '.' on a line by itself)\n"; system ($PLOD); } elsif ($_ =~ /^\//) { my $search = substr ($_, 1); open (S, "-|") || exec ($PLOD, "-g", $search); my @match = (); close (S); my $tmp = POSIX::tmpnam(); open (S, ">$tmp"); print S @match; close (S); system ($PAGER, $tmp); unlink ($tmp); } elsif ($_ =~ /^end$/i || ord($_) == 27) { &end_entry(); } elsif ($_ =~ /^quit$/i || $_ =~ /^exit$/i) { &plodshell_quit(); } elsif ($_ =~ /^pager$/i || $_ =~ /^history$/i || $_ =~ /^less$/i) { system ($PLOD, "-P"); } elsif ($_ =~ /^help/i || $_ =~ /\?/) { print "enter a line by itself to enter that line into plod\n"; print "commands:\n"; print " ^ enter plod interactive mode (\"plod\")\n"; print " /string search for \"string\" and return entire plod entries (\"plod -g string\")\n"; print " quit exit plodshell\n"; print " exit exit plodshell\n"; print " ^D exit plodshell\n"; print " pager show current plod log file (\"plod -P\")\n"; print " history show current plod log file (\"plod -P\")\n"; print " less show current plod log file (\"plod -P\")\n"; print " [esc] signify ending time for previous entry\n"; print " end signify ending time for previous entry\n"; print " ^C signify ending time for previous entry\n"; } else { system ($PLOD, $_); } print $PROMPT; } &plodshell_quit(); } sub sig_end_entry { &end_entry(); print $PROMPT; } sub end_entry { system ($PLOD, "end previous entry"); print "END\n"; } sub plodshell_quit { system ($PLOD, "plodshell exit"); print "\n"; exit; }