Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | package Psh::Strategy::Bang; |
2 | ||
3 | require Psh::Strategy; | |
4 | ||
5 | ||
6 | =item * C<bang> | |
7 | ||
8 | If the input line starts with ! all remaining input will be | |
9 | sent unchanged to /bin/sh | |
10 | ||
11 | =cut | |
12 | ||
13 | ||
14 | @Psh::Strategy::Bang::ISA=('Psh::Strategy'); | |
15 | ||
16 | sub consumes { | |
17 | return Psh::Strategy::CONSUME_LINE; | |
18 | } | |
19 | ||
20 | sub runs_before { | |
21 | return qw(brace); | |
22 | } | |
23 | ||
24 | sub applies { | |
25 | return 'pass to sh' if substr(${$_[1]},0,1) eq '!'; | |
26 | } | |
27 | ||
28 | sub execute { | |
29 | my $command= substr(${$_[1]},1); | |
30 | ||
31 | my $fgflag = 1; | |
32 | if ($command =~ /^(.*)\&\s*$/) { | |
33 | $command= $1; | |
34 | $fgflag=0; | |
35 | } | |
36 | ||
37 | Psh::OS::fork_process( $command, $fgflag, $command, 1); | |
38 | return (1,undef); | |
39 | } | |
40 | ||
41 | 1; |