=head1 NAME

pshconfig - Configuring the Perl Shell

=for README
Please read the perlpod manpage! Pay particular attention to the markup
sequences (B<>, C<>, I<>, etc.).

=head1 SYNOPSIS

How to configure the Perl Shell

=head1 DESCRIPTION

Perl Shell uses a built-in, unified configuration system. All essential
configuration is done by choosing a set of evaluation strategies, using
the C<strategy> builtin, or by setting options, using the C<option> builtin.

=head2 CONFIGURATION OPTIONS

All options marked as (ENV) inherit their settings from the current
environment.

All options marked as (EARLY) must be set in the pshrc file or earlier to
be evaluated.

=over 4

=item * B<array_exports>

Contains a list of environment variables which should be tied
to arrays. The key of the hash is the name of the variable, the
value is the delimiter of the list (e.g. ':' in PATH). The
default value for array_exports currently contains PATH, CLASSPATH,
LD_LIBRARY_PATH, FIGNORE and CDPATH.

=item * B<cdpath> (ENV)

A list of paths of directories in which the C<cd> builtin
should search for its argument. Defaults to ".".

=item * B<echo>

Controls whether the processing loop saves and displays the Perl value 
of executing a line of input. Three cases are distinguished: a false
value, in which case no results are displayed; a subroutine reference, 
in which case the subroutine is called with the results (this may be
multiple arguments if the eval returned an array) and should return
true to display, false to not; or a true (scalar) value, in which case 
any non-undef, non-empty value is displayed.

In addition to displaying the value, it is pushed onto the array
determined by C<$Psh::result_array>.
Note that scalar values are pushed directly onto this array, but array
values are pushed by reference. 

=item * B<fignore> (ENV)

A list (separated by the path separator) of file endings to
ignore when performing TAB completion. No default.

=item * B<history_file> 

The filename B<psh> will use to save the command history in from one
invocation to the next, if B<save_history> is set.

Default is "F<$ENV{HOME}/.${bin}_history>".


=item * B<histsize> (ENV) (EARLY)

The maximum number of lines to save in the history file.
Defaults to 50.

=item * B<ignoredie>

If set, B<psh> will attempt to continue after internal
errors.

=item * B<ignoreeof> (ENV)

Controls the action of the shell on receipt of an EOF character as the
sole input.  If set, the value is the number of consecutive EOF characters
typed as the first characters on an input line before bash exits.
If the variable exists but does not have a numeric value, the default value
is 10. If it does not exist, EOF signifies the end of input to the shell.

=item * B<ignoresegfault> (EARLY)

If set, Perl Shell will try to ignore all segementation faults. Use this
at your own risk!

=item * B<path> (ENV)

A list of directories to search for executables.

=item * B<ps1> (ENV)

This is the standard prompt. It may contain a string or a code reference.
Please see below for more information.

=item * B<ps2> (ENV)

This is the continuation prompt.

=item * B<trace>

If set, the shell will display each line again before it executes it.

=item * B<window_title>

Controls the window title in interactive use. See prompt evaluation
for escape codes.

=item * B<save_history>

If this is true, the command history is saved in file C<$Psh::history_file>
from one invocation of B<psh> to the next.

=head1 PROMPT STRINGS

Setting the variable I<ps1> to a string will cause that string
to be used as the prompt-string. Setting it to a subroutine reference
causes the result of running that subroutine to be used each time.
For example,

  option ps1= sub { $i++; "psh [$i]\$ "; }

will cause the prompt to be C<psh [1]$> followed by C<psh [2]$>, and so on.

B<psh> uses some of the same ``prompting variables'' as B<bash>. They are
accessed by placing a backslash followed by the code in the prompt string,
either hard coded, or as returned by the prompt string function. The
variables supported are:

=over 4

=item d The date in ``Weekday Month Day'' format

=item E The escape character

=item h The short hostname

=item H The long hostname

=item n A carriage return and line feed

=item s The name of the shell

=item t The current time in HH:MM:SS format

=item u The username of the current user

=item w The current working directory

=item W The basename of the current working directory

=item # The command number of the current command

=item $ `#' if the effective UID is zero, else `$'

=item [ ] Used for Term::ReadLine::Gnu to ignore control characters while determining the length of the prompt

=back

Please note that bash's support of backticks to execute code from within the prompt is not supported in psh. Instead use the newer syntax \$(command) which is also support by bash.

Custom prompting variables may be added by adding entries to the array
I<%Psh::prompt_vars> keyed by the single character code. The entries
should be subroutine references that return the replacement string.

=head1 PSH SCALAR VARIABLES

B<psh> makes a number of variables and functions accessible to the
user in the C<Psh::> package for configuration or utility
purposes. Their default values are given in parentheses below. If the
variable is also marked "[late]", then it is undefined at the start of 
the F<.pshrc> file, but any value given to it during that file will be 
used instead of the default setting.

=over 4

=item I<$Psh::bin> (the basename of the file B<psh> was invoked by)

The name of the current shell.

=item I<$Psh::cmd>

The command serial number in the currently-executing processing loop.

=item I<$Psh::currently_active> (0)

The pid of the process B<psh> will currently forward signals to, or 0
if B<psh> will handle the signals internally. Usually
0 unless B<psh> is waiting for a process in the "foreground".

=item I<$Psh::debugging> (the value of the B<-d> option or 0)

Whether B<psh>'s internal debugging output should be produced. If this
variable is set to 1, all available debug output will be shown. If
this is set to a string to characters, only debug output belonging
to the classes signified by the characters will be shown. Debug
classes etc. are in B<pshdevel>

=item I<$Psh::eval_preamble> ("package main;")

Every Perl expression that B<psh> evaluates as part of its read-eval loop
is prepended with this string, intended primarily to set the expected
package context.

=item I<$Psh::host> (the output of "C<hostname -s>") [late]

The short host name of the machine B<psh> is currently running on.

=item I<$Psh::interactive>

This is not a customization variable but a flag which tells wether
you are currently in interactive mode (1) or processing a file (0)

=item I<$Psh::login_shell> (0)

Set to true if B<psh> is the user's login shell. On systems where this
does not apply, set to true unless called from another instance of B<psh>.

=item I<$Psh::longhost> (the output of "C<hostname>") [late]

The fully qualified host name of the machine B<psh> is running on.

=item I<$Psh::result_array> ('Psh::val') 

Controls where the results of Perl evaluations saved via C<$Psh::echo> 
will go. It may be a reference to an array, or the string name of an
array.

=item I<$Psh::which_regexp> ('^[-a-zA-Z0-9_~+]*$')

When C<Psh::Util::which> is asked to locate a filename in the current
PATH, it will only look for filenames which match this regexp. Names
that do not match this regexp will automatically come back "not found".

=back


=head1 PSH ARRAY VARIABLES

=over 4

=item I<@Psh::Completion::bookmarks> ( from /etc/hosts )

Supposed to contain your most used IP numbers, hostnames or URLs.
Those will be eligible for TAB completion if you add a command
for completion using complete C<-A> hostname command. C<psh> will
initialize this list with your /etc/hosts file

=item I<@Psh::history>

An array of lines to write to the history file when B<psh> exits, only
filled when the ReadLine module doesn't handle the history file.

=item I<@Psh::val>

The default array where B<psh> stores away the results of executing
lines, as described in C<$Psh::echo> above. 

=back


=head1 PSH HASH VARIABLES

=over 4

=item I<%Psh::Prompt::prompt_vars>

The keys of this hash are single characters, and the values are
subroutine references that implement the given escape character in
prompt strings. (See L<PROMPT STRINGS> below.)

=back


=head1 COPYRIGHT

Copyright (C) 1999-2003 Gregor N. Purdy. All rights reserved.
This script is free software. It may be copied or modified according
to the same terms as Perl itself.


=cut
