## do not modify - autogenerated ##
package Psh
::Strategy
::Bang
;
If the input line starts with ! all remaining input will be
sent unchanged to /bin/sh
@Psh::Strategy
::Bang
::ISA
=('Psh::Strategy');
return Psh
::Strategy
::CONSUME_LINE
;
return 'pass to sh' if substr(${$_[1]},0,1) eq '!';
my $command= substr(${$_[1]},1);
if ($command =~ /^(.*)\&\s*$/) {
Psh
::OS
::fork_process
( $command, $fgflag, $command, 1);
package Psh
::Strategy
::Perl
;
If the input line starts with p! all remaining input will be
sent unchanged to the perl interpreter
@Psh::Strategy
::Perl
::ISA
=('Psh::Strategy');
return Psh
::Strategy
::CONSUME_LINE
;
return qw(built_in brace);
return 'perl evaluation' if substr(${$_[1]},0,2) eq 'p!';
${$_[1]}= substr(${$_[1]},2);
Psh
::Strategy
::Eval
::execute
(@_);
package Psh
::Strategy
::Brace
;
Input within curly braces will be sent unchanged to the perl
@Psh::Strategy
::Brace
::ISA
=('Psh::Strategy');
return Psh
::Strategy
::CONSUME_TOKENS
;
return 'perl evaluation' if substr(${$_[1]},0,1) eq '{';
Psh
::Strategy
::Eval
::execute
(@_);
package Psh
::Strategy
::Built_in
;
require Psh
::Support
::Builtins
;
@Psh::Strategy
::Built_in
::ISA
=('Psh::Strategy');
Psh
::Support
::Builtins
::build_autoload_list
();
sub new
{ Psh
::Strategy
::new
(@_) }
return Psh
::Strategy
::CONSUME_TOKENS
;
return qw(executable auto_resume auto_cd);
if( $fnname= Psh
::Support
::Builtins
::is_builtin
($fnname)) {
eval 'use Psh::Builtins::'.ucfirst($fnname);
Psh
::Util
::print_error_i18n
('builtin_failed',$@
);
my $rest= join(' ',@words);
$coderef= *{join('','Psh::Builtins::',ucfirst($command),
return (1,sub { &{$coderef}($rest,\
@words); }, [], 0, undef );
package Psh
::Strategy
::Perlfunc
;
Tries to detect perl builtins - this is helpful if you e.g. have
a print command on your system. This is a small, minimal version
without options which will react on your own sub's or on a limited
list of important perl builtins. Please also see the strategy
@Psh::Strategy
::Perlfunc
::ISA
=('Psh::Strategy');
sub new
{ Psh
::Strategy
::new
(@_) }
return Psh
::Strategy
::CONSUME_TOKENS
;
return qw(perlscript auto_resume executable);
print 1 printf 1 push 1 pop 1 shift 1 unshift 1 system 1
chop 1 chomp 1 use 1 for 1 foreach 1 sub 1 do 1
# catch "join(':',@foo)" here as well:
$fnname = (split('\(', $fnname))[0];
if (exists $perl_builtins{$fnname}) {
my $needArgs = $perl_builtins{$fnname};
or scalar(@
{$_[2]}) >= $needArgs)) {
} elsif( $fnname =~ /^([a-zA-Z0-9_]+)\:\:([a-zA-Z0-9_:]+)$/) {
my $needArgs = $perl_builtins{$2};
and ($parenthesized or scalar(@
{$_[2]}) >= $needArgs)) {
$qPerlFunc = (Psh
::PerlEval
::protected_eval
("defined(&{'$fnname'})"))[0];
} elsif( $fnname =~ /^[a-zA-Z0-9_]+$/) {
$qPerlFunc = (Psh
::PerlEval
::protected_eval
("defined(&{'$fnname'})"))[0];
return $line if $qPerlFunc;
return Psh
::Strategy
::Eval
::execute
(@args);
package Psh
::Strategy
::Executable
;
This strategy will search for an executable file and execute it
@Psh::Strategy
::Executable
::ISA
=('Psh::Strategy');
return Psh
::Strategy
::CONSUME_TOKENS
;
my $executable= Psh
::Util
::which
($com);
return $executable if defined $executable;
if (Psh
::Options
::get_option
('expansion') and
(!$Psh::current_options
or !$Psh::current_options
->{noexpand
})) {
@words= Psh
::PerlEval
::variable_expansion
(\
@words);
if (Psh
::Options
::get_option
('globbing') and
(!$Psh::current_options
or !$Psh::current_options
->{noglob
})) {
@words = Psh
::Parser
::glob_expansion
(\
@words);
@words = map { Psh
::Parser
::unquote
($_)} @words;
return (1,join(' ',$executable,@words),[$executable,$tmp,@words], 0, undef, );
package Psh
::Strategy
::Eval
;
All input will be evaluated by the perl interpreter without
@Psh::Strategy
::Eval
::ISA
=('Psh::Strategy');
sub new
{ Psh
::Strategy
::new
(@_) }
return Psh
::Strategy
::CONSUME_TOKENS
;
return 'perl evaluation';
if( $_[4]) { # we are second or later in a pipe
$todo=~ s/\} ?([qg])\s*$/\}/;
if( $mods eq 'q' ) { # non-print mode
$code='while(<STDIN>) { @_= split /\s+/; '.$todo.' ; }';
} elsif( $mods eq 'g') { # grep mode
$code='while(<STDIN>) { @_= split /\s+/; print $_ if eval { '.$todo.' }; } ';
$code='while(<STDIN>) { @_= split /\s+/; '.$todo.' ; print $_ if $_; }';
return (1,sub {return 1,Psh
::PerlEval
::protected_eval
($code,'eval'); }, [], 0, undef);
local @Psh::tmp
= Psh
::PerlEval
::protected_eval
($todo,'eval');
return ((@Psh::tmp
&& $Psh::tmp
[0])?
1:0, @Psh::tmp
);