pl can convert the output of commands to an arraypwd doesn't work.cd doesn't work.
see also: http://www.perl.com/language/ppt/ ``Perl Power Tools: The Unix Reconstruction Project''
The pl homepage is http://plshell.sourceforge.net/,
the latest release can be downloaded from the project page at
http://sourceforge.net/projects/plshell.
pl is a minimal Perl shell, providing continuations of unterminated
quotations, autoloading of functions, and the option to convert
line-based data to arrays on-the-fly. Unlike psh, pl does not provide
sh-like constructs; all commands are valid Perl.
pl should be a complete replacement for sh(1), not in terms of
commands, but functionality. Perl is a complicated program and
can easily replace many small /bin commands. Why use /bin/unlink
when you can use unlink()?
In the future, it may be possible to rm -rf /bin and do everything
through pl (or perl) instead of sh, resulting in a sort of Perl
operating system. The possibilities...
What follows is description of some things pl can do.
pl provides:
Unlike psh, which prefixes its continatuion prompt with ``>'', and
Python, which prefixes its with ``...'', pl sets the continuation prompt
to the token that would match end of the quotation. Here are some examples:
#! "foo
"? bar"
foo\nbar
#! qq(
)? )
\n
#! <<EOF
\nEOF? hello world
\nEOF? blah blah blah
\nEOF? EOF
hello world\nblah blah blah\n
#!
pl can convert the output of commands to an array
#! ls
ARRAY(0x80ea6b0)
0 cat\n
1 cols\n
2 data\n
3 default_loader\n
ls is handled using line_loader.
pl has its own (very simplistic) implementation of cat:
#! cat("cat")
autoloading main::cat: cat
SCALAR(0x8061734)
sub # cat
{
[...]
As you can see it returns a scalar.
In addition to line_loader, pl has a default loader which consists of:
sub #default
{
my ($fn, @args) = @_;
system($fn, @args);
}
If you're knowledgeable at Perl, pl should be easy to figure out. Note,
parenthesis are required to auto-load a function from /usr/bin (that is,
until all command-line utilities are rewritten in Perl) initially. Read the
source for all the details.
pwd doesn't work.
use Cwd;
getcwd();
cd doesn't work.
chdir()
| isn't allowed because it is Perl's bitwise OR operator, and pl doesn't
redefine any Perl operators. You still can use pipes with open, see
perlfunc(1).
Set $pre to any valid Perl code. This variable is eval'd before input.
For example, assuming Cwd is loaded:
$pre = q(print getcwd(), "#! ") # set to current directory + #!
You can also set $post, it is evaluated after each command. By default,
$post is print "\n".
$pre_more is evaluated before inputting each line of continued input, by
default it prints the terminator and a question mark.
At the moment this is very minimal, GNU readline isn't used. Patches welcome.
@out.
$_.
Internally, pl reads input into $in and saves it to $_ after
the command is finished; accessing $in can be self-referential and this may
cause problems, so just access $_.
Type your EOF character (^D on Unix, ^Z on Windows). This will work even
if completing an incomplete quotation.
pl is very small and incomplete, if you're looking for a Perl-based shell for
day-to-day use, psh is much better. psh does many things one would expect in
a shell, including pipes, space-separated command line arguments, the works.
Get it at http://psh.sourceforge.net or http://www.gregorpurdy.com/gregor/psh.
For an all-in-one program, capable of performing all basic system tasks, pl
is suitable (Perl supports most system calls), although BusyBox is a better
choice for embedded systems. Perl isn't small. BusyBox is available at
http://www.busybox.net/.
Jeff Connelly <shellreef+pl@gmail.com>
Feedback is welcome.