• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ferki / Rex / 15240232617

28 Feb 2025 09:08AM UTC coverage: 50.961% (+10.2%) from 40.73%
15240232617

push

github

ferki
Use placeholders for template hints

10072 of 19764 relevant lines covered (50.96%)

101.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

8.89
/lib/Rex/Interface/Shell/Csh.pm
1
#
2
# (c) Jan Gehring <jan.gehring@gmail.com>
3
#
4

5
package Rex::Interface::Shell::Csh;
6

7
use v5.12.5;
4✔
8
use warnings;
4✔
9

10
our $VERSION = '9999.99.99_99'; # VERSION
11

12
use Rex::Interface::Shell::Base;
4✔
13
use base qw(Rex::Interface::Shell::Base);
4✔
14

15
sub new {
16
  my $class = shift;
×
17
  my $proto = ref($class) || $class;
×
18
  my $self  = $proto->SUPER::new(@_);
×
19

20
  bless( $self, $class );
×
21

22
  return $self;
×
23
}
24

25
sub path {
26
  my ( $self, $path ) = @_;
×
27
  $self->{path} = $path;
×
28
}
29

30
sub source_global_profile {
31
  my ( $self, $parse ) = @_;
×
32
  $self->{source_global_profile} = $parse;
×
33
}
34

35
sub source_profile {
36
  my ( $self, $parse ) = @_;
×
37
  $self->{source_profile} = $parse;
×
38
}
39

40
sub set_locale {
41
  my ( $self, $locale ) = @_;
×
42
  $self->{locale} = $locale;
×
43
}
44

45
# sub set_env {
46
#   my ( $self, $env ) = @_;
47
#   my $cmd = undef;
48
#
49
#   die("Error: env must be a hash")
50
#     if ( ref $env ne "HASH" );
51
#
52
#   while ( my ( $k, $v ) = each($env) ) {
53
#     $cmd .= "setenv $k \"$v\"; ";
54
#     $self->{env_raw} .= "$k $v";
55
#   }
56
#
57
#   $self->{env} = $cmd;
58
# }
59

60
sub exec {
61
  my ( $self, $cmd, $option ) = @_;
×
62

63
  if ( exists $option->{path} ) {
×
64
    $self->path( $option->{path} );
×
65
  }
66

67
  # if ( exists $option->{env} ) {
68
  #   $self->set_env( $option->{env} );
69
  # }
70

71
  my $complete_cmd = $cmd;
×
72

73
  # if we need to execute without an sh command,
74
  # use the format_cmd key
75
  if ( exists $option->{no_sh} ) {
×
76
    $complete_cmd = $option->{format_cmd};
×
77
  }
78

79
  if ( exists $option->{cwd} ) {
×
80
    $complete_cmd = "cd $option->{cwd} && $complete_cmd";
×
81
  }
82

83
  if ( $self->{path} && !exists $self->{__env__}->{PATH} ) {
×
84
    $complete_cmd = "set PATH=$self->{path}; $complete_cmd ";
×
85
  }
86

87
  if ( $self->{locale} ) {
×
88
    $complete_cmd = "set LC_ALL=$self->{locale} ; $complete_cmd ";
×
89
  }
90

91
  if ( $self->{source_profile} ) {
×
92

93
    # csh is using .login
94
    $complete_cmd = "source ~/.login >& /dev/null ; $complete_cmd";
×
95
  }
96

97
  if ( $self->{source_global_profile} ) {
×
98
    $complete_cmd = "source /etc/profile >& /dev/null ; $complete_cmd";
×
99
  }
100

101
  if ( exists $self->{__env__} ) {
×
102
    if ( ref $self->{__env__} eq "HASH" ) {
×
103
      for my $key ( keys %{ $self->{__env__} } ) {
×
104
        my $val = $self->{__env__}->{$key};
×
105
        $val =~ s/"/"'"'"/gms;
×
106
        $complete_cmd = " setenv $key \"$val\" ; $complete_cmd ";
×
107
      }
108
    }
109
    else {
110
      $complete_cmd = $self->{__env__} . " $complete_cmd ";
×
111
    }
112
  }
113

114
# this is due to a strange behaviour with Net::SSH2 / libssh2
115
# it may occur when you run rex inside a kvm virtualized host connecting to another virtualized vm on the same hardware
116
  if ( Rex::Config->get_sleep_hack ) {
×
117
    $complete_cmd .= " ; set f=\$? ; sleep .00000001 ; exit \$f";
×
118
  }
119

120
  # rewrite the command again
121
  if ( exists $option->{format_cmd} ) {
×
122
    $complete_cmd =~ s/\{\{CMD\}\}/$cmd/;
×
123
  }
124

125
  return $complete_cmd;
×
126
}
127

128
1;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc