package Shell::EnvImporter::Shell - Shell abstraction for Shell::EnvImporter
use Shell::EnvImporter;
# Have Shell::EnvImporter create the shell object
my $sourcer = Shell::EnvImporter->new(
command => $command,
shell => $shellname,
auto_run => 0,
);
# Fetch the shell object
my $shellobj = $sourcer->shellobj;
# Set the shell invocation flags
$shellobj->flags($flags);
# Set an alternative 'env' command
$shellobj->envcmd($envcmd);
# Manipulate the ignore list:
# - set
$shellobj->ignore(qw(_ PWD SHLVL));
# - add to
$shellobj->ignore_push(qw(HOME));
# - clear
$shellobj->ignore_clear();
# Run the command with the modified shell
$sourcer->run();
Shell::EnvImporter allows you to import environment variable changes exported by
an external script or command into the current environment. The
Shell::EnvImporter::Shell object provides more control over interaction with
the shell.
- flags()
- flags(@flags)
- flags_push(@flags)
- Get or set the flags passed to the shell. E.g. default Bash flags are
'-norc -noprofile -c', to prevent the sourcing of startup scripts. Note:
If you set the flags, you MUST include the '-c' flag (or equivalent) for
passing commands to the shell on the command line.
- envcmd()
- envcmd($command)
- Get or set the command used to print out the environment. E.g., under the
Bourne shell and variants, the default command is 'env'. Since 'env' only
prints exported environment variables, you can change the command to 'set'
to see all shell environment variables, exported or not.
- ignore()
- ignore(@variables)
- ignore_push(@variables)
- ignore_clear()
- Get, set, append to, or clear the shell ignore list. The shell ignore list
is a list of variables that are never imported. These are generally
variables that are changed automatically by the shell (e.g. SHLVL and
PWD), providing little information to a noninteractive shell.
David Faraldo, <dfaraldo@cpan.org>
Copyright (C) 2005-2006 by Dave Faraldo
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself. No warranty is expressed or implied.