Psh/Builtins/Unalias.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 39 CC 3 SCAR 19.5
CC
3
Cov
0%
bi_unalias
12.0
cmpl_unalias
2.0
BEGIN
2.0
CRAP 7.0
1 package Psh::Builtins::Unalias;
2  
3 require Psh::Util;
4 require Psh::Support::Alias;
5  
6 =item * C<unalias NAME | -a | all]>
7  
8 Removes the alias with name <C<I<NAME>> or all aliases if either <C<I<-a>>
9 (for bash compatibility) or <C<I<all>> is specified.
10  
11 =cut
12  
13 sub bi_unalias {
14 my $name= shift;
15 if( ($name eq '-a' || $name eq 'all') and !Psh::Support::Alias::is_aliased($name) ) {
16 %Psh::Support::Alias::aliases=();
17 return (1,undef);
18 } elsif( Psh::Support::Alias::is_aliased($name)) {
19 delete($Psh::Support::Alias::aliases{$name});
20 return (1,undef);
21 } else {
22 Psh::Util::print_error_i18n('unalias_noalias', $name);
23 return (0,undef);
24 }
25 return (0,undef);
26 }
27  
28  
29 sub cmpl_unalias {
30 my $text= shift;
31 return (1,grep { Psh::Util::starts_with($_,$text) } Psh::Support::Alias::get_alias_commands());
32 }
33  
34 1;