Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / Psh / Strategy / Executable.pm
CommitLineData
86530b38
AT
1package Psh::Strategy::Executable;
2
3
4=item * C<executable>
5
6This strategy will search for an executable file and execute it
7if possible.
8
9=cut
10
11require Psh::Strategy;
12require Psh::Options;
13
14@Psh::Strategy::Executable::ISA=('Psh::Strategy');
15
16my %built_ins=();
17
18sub consumes {
19 return Psh::Strategy::CONSUME_TOKENS;
20}
21
22sub runs_before {
23 return qw(eval);
24}
25
26sub applies {
27 my $com= @{$_[2]}->[0];
28 my $executable= Psh::Util::which($com);
29 return $executable if defined $executable;
30 return '';
31}
32
33sub execute {
34 my $inputline= ${$_[1]};
35 my @words= @{$_[2]};
36 my $tmp= shift @words;
37 my $executable= $_[3];
38
39 if (Psh::Options::get_option('expansion') and
40 (!$Psh::current_options or !$Psh::current_options->{noexpand})) {
41 @words= Psh::PerlEval::variable_expansion(\@words);
42 }
43 if (Psh::Options::get_option('globbing') and
44 (!$Psh::current_options or !$Psh::current_options->{noglob})) {
45 @words = Psh::Parser::glob_expansion(\@words);
46 }
47 @words = map { Psh::Parser::unquote($_)} @words;
48
49 return (1,join(' ',$executable,@words),[$executable,$tmp,@words], 0, undef, );
50}
51
521;