psh
view release on metacpan or search on metacpan
CHANGES.pod view on Meta::CPAN
There was a small, not very often occurring bug related to the usage of
Env::Array, due to a typo
=item *
Handling of ~ for username expansion should be bug-free now
=item *
The help builtin sometimes returned the wrong help (e.g. C<help set>
returned the help of setenv)
=item *
The parser parsed '&&' as if the user entered '& &&'.
=item *
C<@_> and C<$_> are saved between input lines.
=item *
CHANGES.pod view on Meta::CPAN
=head2 Bug Fixes
=over 4
=item *
Generation of weekday names.
=item *
Small fixes for B<setenv>, print_list and abs_path.
=item *
Fixed signal description generation.
=back
=cut
CHANGES.pod view on Meta::CPAN
=item *
Pipelines.
=item *
Initial internationalization.
=item *
New built-ins: C<alias>, C<export>, C<setenv>.
=item *
A flexible set of evaluation strategies that can be
selected or reordered by setting a configuration
variable.
=item *
Prompt strings can have escapes like C<\07> (ASCII C<BEL>) or
lib/Psh/Builtins/Export.pm view on Meta::CPAN
package Psh::Builtins::Export;
require Psh::Support::Env;
require Psh::Options;
require Psh::Util;
=item * C<export VAR [=VALUE]>
Just like setenv, below, except that it also ties the variable (in the
Perl sense) so that subsequent changes to the variable automatically
affect the environment. Variables who are lists and appear in option
'array_exports' will also by tied to the array of the same name.
Note that the variable must be specified without any Perl specifier
like C<$> or C<@>.
=cut
sub bi_export
{
my $var = Psh::Support::Env::do_setenv(@_);
if ($var) {
my @result = Psh::PerlEval::protected_eval("tied(\$$var)");
my $oldtie = $result[0];
if (defined($oldtie)) {
if (ref($oldtie) ne 'Env') {
Psh::Util::print_warning_i18n('bi_export_tied',$var,$oldtie);
}
} else {
Psh::PerlEval::protected_eval("use Env '$var';");
my $ae= Psh::Options::get_option('array_exports');
lib/Psh/Builtins/Firsttime.pm view on Meta::CPAN
$aliases{$key}=$value;
} elsif ($line=~/^\s*function (\S+) \{/) {
my $tmp=$line;
while (Psh::Parser::incomplete_expr($tmp)>0 && <FILE>) {
$tmp.=$_;
}
$env.="$tmp\n";
} elsif ($line=~/^\s*(\S+)\=(.*)$/) {
my $key= uc($1);
my $value= _change_env_value($2);
$env.="setenv $key=$value\n";
} elsif ($line=~/^\s*export (\S+)\=(.+)$/) {
my $key= uc($1);
my $value= _change_env_value($2);
$env.="setenv $key=$value\n";
}
}
close(FILE);
return undef;
}
sub _parse_csh_file {
my $file= shift;
lib/Psh/Builtins/Firsttime.pm view on Meta::CPAN
my $line=$_;
chomp $line;
next if $line=~/^\s*#/;
if ($line=~/^\s*alias (\S+)\s+(.+)$/) {
my $key= $1;
my $value= $2;
if (exists $aliases{$key}) {
print STDERR "Warning: alias $key redefined.\n";
}
$aliases{$key}=$value;
} elsif ($line=~/^\s*setenv\s+(\S+)\s+(.+)$/) {
my $key= uc($1);
my $value= _change_env_value($2);
$env.="setenv $key=\"$value\"\n";
} elsif ($line=~/^\s*set\s+(\S+)\=\s*["]([^\"]+)["]\s*$/ ||
$line=~/^\s*set\s+(\S+)\=\s*[']([^\']+)[']\s*$/ ||
$line=~/^\s*set\s+(\S+)\=\s*(\([^\']+\))\s*$/ ||
$line=~/^\s*set\s+(\S+)\=([^#\s]+)\s*/) {
my $key= uc($1);
my $value= _change_env_value($2);
$env.="setenv $key=$value\n";
}
}
close(FILE);
return undef;
}
sub _change_env_value
{
my $val= shift;
return $val if ($val=~/^\'(.*)\'$/); # do not modify if single quotes
lib/Psh/Builtins/Setenv.pm view on Meta::CPAN
package Psh::Builtins::Setenv;
require Psh::Support::Env;
require Psh::Util;
=item * C<setenv NAME [=] VALUE>
Sets the environment variable NAME to VALUE.
=cut
sub bi_setenv
{
my $var = Psh::Support::Env::do_setenv(@_);
if (!$var) {
Psh::Util::print_error_i18n('usage_setenv');
return (0,undef);
}
return (1,undef);
}
1;
lib/Psh/Locale/Default.pm view on Meta::CPAN
cannot_read_script=%2: Cannot read script '%1'
cannot_open_script=%2: Cannot open script '%1'
redirect_file_missing=%2: Error: Filename missing after redirect '%1'.
evaluates_under=%1 evaluates under strategy %2 by %3
# Various builtins
unalias_noalias=unalias: '%1' not an alias
bi_readline_header=Using Readline %1, with features:
help_header=psh supports following built in commands
no_help=Sorry, help for builtin %1 is not available
usage_setenv=Usage: setenv <variable> <value>
usage_export=Usage: export <variable> [=] <value>\n export <variable
usage_kill=Usage: kill <sig> <pid>| -l
usage_delenv=Usage: delenv <var> [<var2> <var3> ...]
bi_export_tied=Variable \$%1 is already tied via %2, cannot export.
bi_kill_no_such_job=kill: No such job %1
bi_kill_no_such_jobspec=kill: Unknown job specification %1
bi_kill_error_sig=kill: Error sending signal %2 to process %1
bi_which_no_command=which: requires a command or command line as argument
bi_alias_none=No aliases.
bi_alias_cant_a=Cannot alias '-a'.
lib/Psh/Locale/German.pm view on Meta::CPAN
cannot_read_script=%2: Kann Skript '%1' nicht lesen
cannot_open_script=%2: Kann Skript '%1' nicht öffnen
redirect_file_missing=%2: Fehler: Dateiname fehlt nach Umleitung '%1'.
evaluates_under=%1 wird durch die Strategie %2 mit %3 ausgeführt
# Various builtins
unalias_noalias=unalias: '%1' ist kein Alias
bi_readline_header=Verwende Readline Modul %1, mit folgenden Eigenschaften:
help_header=psh unterstützt folgende eingebaute Kommandos:
no_help=Hilfe für Kommando %1 ist leider nicht verfügbar.
usage_setenv=Verwendung: setenv <variable> <value>
usage_export=Verwendung:\nexport <variable> [=] <value>\nexport <variable
usage_kill=Verwendung: kill <sig> <pid>| -l
bi_export_tied=Variable \$%1 ist bereits an %2 gebunden, kann nicht exportiert werden.
bi_kill_no_such_job=kill: Job %1 unbekannt
bi_kill_no_such_jobspec=kill: Unbekannte Jobspezifikation %1
bi_kill_error_sig=kill: Fehler beim Senden von Signal %2 an Prozess %1
bi_which_no_command=which: benötigt ein Argument
bi_alias_none=Keine Aliase.
bi_alias_cant_a=Es ist nicht erlaubt einen Alias mit dem Namen '-a' anzulegen.
bi_jobs_none=Keine Jobs.
lib/Psh/Support/Env.pm view on Meta::CPAN
package Psh::Support::Env;
#
# string do_setenv(string command)
#
# command is of the form "VAR VALUE" or "VAR = VALUE" or "VAR"; sets
# $ENV{VAR} to "VALUE" in the first two cases, or to "$VAR" in the
# third case unless $VAR is undefined. Used by the setenv and export
# builtins. Returns VAR (which is a string with no $).
sub do_setenv
{
my $arg = shift;
if( $arg=~ /^\s*(\w+)(\s+|\s*=\s*)(.+)/ ) {
my $var= $1;
my $value= $3;
if( $value=~ /^\'(.*)\'\s*$/ ) {
# If single quotes were used, do not interpret
# variables
$ENV{$var}=$1;
} else {
$var =~ s/^\$//;
if ($value=~ /^\"(.*)\"/) {
$value=$1;
}
# Use eval so that variables may appear on RHS
# ($value); use protected_eval so that lexicals
# in this file don't shadow package variables
Psh::PerlEval::protected_eval("\$ENV{$var}=\"$value\"", 'do_setenv');
}
return $var;
} elsif( $arg=~ /(\w+)/ ) {
my $var= $1;
$var =~ s/^\$//;
Psh::PerlEval::protected_eval("\$ENV{$var}=\$$var if defined(\$$var);",
'do_setenv');
return $var;
}
return '';
}
1;
( run in 0.463 second using v1.01-cache-2.11-cpan-a1d94b6210f )