Zoidberg::Shell - A scripting interface to the Zoidberg shell


        use Zoidberg::Shell;
        my $shell = Zoidberg::Shell->current();
        # Order parent shell to 'cd' to /usr
        # If you let your shell do 'cd' that is _NOT_ the same as doing 'chdir'
        $shell->shell(qw{cd /usr});
        # Let your parent shell execute a logic list with a pipeline
        $shell->shell([qw{ls -al}], [qw{grep ^d}], 'OR', [qw{echo some error happened}]);
        # Create an alias
        $shell->alias({'ls' => 'ls --color=auto'});
        # since we use Exporter::Tidy you can also do things like this:
        use Zoidberg::Shell _prefix => 'zoid_', qw/shell alias unalias/;
        zoid_alias({'perlfunc' => 'perldoc -Uf'});


This module is intended to let perl scripts interface to the Zoidberg shell in an easy way. The most important usage for this is to write 'source scripts' for the Zoidberg shell which can use and change the parent shell environment like /.*sh/ source scripts do with /.*sh/ environments.


Only the subs AUTOLOAD and shell are exported by default. AUTOLOAD works more or less like the one from by Larry Wall, but it includes zoid's builtin functions and commands (also it just prints output to stdout see TODO).

All other methods except new and system can be exported on demand. Be aware of the fact that methods like alias can mask "plugin defined builtins" with the same name, but with an other interface. This can be confusing but the idea is that methods in this package have a scripting interface, while the like named builtins have a commandline interface.

The reason the system can't be exported is because it would mask the perl function system, also this method is only included so zoid's DispatchTable's can use it.

Also you can import an @JOBS from this module. The ':jobs' tag gives you both @JOBS and the job() method.


Be aware: All commands are executed in the parent shell environment.

FIXME document the new export tags, document all routines better


Simple wrapper for the constructor of the Zoidberg class.


Returns the current Zoidberg object, which in turn inherits from this package, or undef when there is no such object.

TODO should also do ipc


Uses the current shell if any, else starts a new one.

system($command, @_)

Opens a pipe to a system command and returns it's output. Intended for when you want to call a command without using zoid's parser and job management. This method has absolutely no intelligence (no expansions, builtins, etc.), you can only call external commands with it.

shell($command, @_)

If $command is a built-in shell function (possibly defined by a plugin) or a system binary, it will be run with arguments @_. The command won't be subject to alias expansion, arguments might be subject to glob expansion. FIXME double check this


Parse and execute $string like it was entered from the commandline. You should realise that the parsing is dependent on grammars currently in use, and also on things like aliases etc.

shell([$command, @_], [..], 'AND', [..])

Create a logic list and/or pipeline. Available tokens are 'AND', 'OR' and 'EOS' (End Of Statement, ';').

shell() allows for other kinds of pseudo parse trees, these can be considered as a kind of "expert mode". See zoiddevel(1) for more details. You might not want to use these without good reason.


Update settings in parent shell.

        # merge hash with current settings hash
        set( { noglob => 0 } );
        # set these bits to true
        set( qw/hide_private_method hide_hidden_files/ );

See zoiduser(1) for a description of the several settings.


Returns the current value for a setting.


Merge %aliases with current alias hash.

        alias( { ls => 'ls ---color=auto' } )

Delete all keys listed in @aliases from the aliases table.


Run another perl script, possibly also interfacing with zoid.

FIXME more documentation on zoid's source scripts


Used to fetch a job object by its spec, for example:

        $shell->job('%-')->kill(); # kill the previous job

All calls that get autoloaded are passed directly to the shell() method. This allows you to use nice syntax like :



FIXME splain @JOBS


An interface to create background jobs

An interface to get input

Can builtins support both perl data and switches ?

Test script

More syntactic sugar :)


Jaap Karssenberg || Pardus [Larus] <>

Copyright (c) 2011 Jaap G Karssenberg and Joel Berger. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Zoidberg, Zoidberg::Utils,