• Use standard line-editing control keys, including filename tab-completion and a command history (curtesy of Term::Readline).

  • End a line with a backslash character to continue it on another line.

  • Enter "<<" followed by return, then several lines of text, followed by return and control-d.

EXAMPLES

Declaring a subroutine

In the below, I use the << notation to enter a multi-line block of Perl, terminated by a control-D.

You can then call any subroutines you've defined on the shell prompt line.

~> perl lib/Shell/Shell.pm
Term::ShellKit: Starting interactive shell
Term::ShellKit> <<

sub count {
  my $count = shift;
  join(', ', ( 0 .. $count ) )
}
^D

Term::ShellKit> count(3)
count(3): 0, 1, 2, 3
Term::ShellKit> count(5)
count(5): 0, 1, 2, 3, 4, 5

Declaring a shell command

To create a new shell command, define a function using the above << syntax.

You can then call those functions with space-separated arguments on the shell prompt line. These commands can use existing shell methods for further interaction with the user.

~> perl lib/Shell/Shell.pm
Term::ShellKit: Starting interactive shell
Term::ShellKit> <<

sub do_count {
  my $count = shift || $Term::ShellKitInput->( 'do_count to: ' );
  $shell->shell_out_lines( join(', ', ( 0 .. $count ) ) );
}
^D

Term::ShellKit> do_count 3
0, 1, 2, 3

Term::ShellKit> do_count  
do_count to: 3
0, 1, 2, 3