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 / Auto_cd.pm
CommitLineData
86530b38
AT
1package Psh::Strategy::Auto_cd;
2
3=item * C<auto_cd>
4
5If the input line matches the name of a directory then
6it will be handled as an implicit cd.
7
8=cut
9
10require Psh::Strategy;
11require Psh::Builtins::Cd;
12
13@Psh::Strategy::Auto_cd::ISA=('Psh::Strategy');
14
15
16sub new { Psh::Strategy::new(@_) }
17
18
19sub consumes {
20 return Psh::Strategy::CONSUME_TOKENS;
21}
22
23sub applies {
24 my $dir= ${$_[2]}[0];
25 return "auto-cd $dir" if -d $dir;
26 return '';
27}
28
29sub execute {
30 my $dir= ${$_[2]}[0];
31 Psh::Builtins::Cd::bi_cd($dir);
32 return (1,undef);
33}
34
35sub runs_before {
36 return qw(perlscript executable);
37}
38
39# Turn on directory completion for first words in line
40$Psh::Completion::complete_first_word_dirs=1;
41
421;