Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Revision history for Rex

[ENHANCEMENTS]
- Quote command arguments on Windows
- Support command environment variables on Windows

[MAJOR]

Expand Down
7 changes: 6 additions & 1 deletion lib/Rex/Interface/Exec/Local.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sub set_env {
if ( ref $env ne "HASH" );

while ( my ( $k, $v ) = each(%$env) ) {
$cmd .= "export $k='$v'; ";
$cmd .= $OSNAME eq 'MSWin32' ? "set $k=$v && " : "export $k='$v'; ";
}
$self->{env} = $cmd;
}
Expand Down Expand Up @@ -87,6 +87,11 @@ sub exec {

$cmd = $new_cmd;
}
else {
if ( $self->{env} ) {
$cmd = $self->{env} . " $cmd";
}
}

Rex::Logger::debug("Executing: $cmd");

Expand Down
7 changes: 2 additions & 5 deletions t/env.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ use Rex::Commands::Run;

$::QUIET = 1;

SKIP: {
skip 'Do not run tests on Windows', 1 if $^O =~ m/^MSWin/;
my $s = run( 'perl', [ '-e', 'print $ENV{REX}' ], env => { 'REX' => 'XER' } );

my $s = run( q(perl -e 'print $ENV{REX}'), env => { 'REX' => 'XER' } );
like( $s, qr/XER/, "run with env" );
}
like( $s, qr/XER/, "run with env" );
7 changes: 5 additions & 2 deletions t/scm/git.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use Test::More;
use Test::Warnings;
use Test::Exception;

use English qw(-no_match_vars);
use File::Spec;
use File::Temp qw(tempdir);
use Rex::Commands;
Expand All @@ -27,9 +28,11 @@ else {
plan skip_all => 'Can not find git command';
}

my $empty_config_file = $OSNAME eq 'MSWin32' ? q() : File::Spec->devnull();

my $git_environment = {
GIT_CONFIG_GLOBAL => File::Spec->devnull(),
GIT_CONFIG_SYSTEM => File::Spec->devnull(),
GIT_CONFIG_GLOBAL => $empty_config_file,
GIT_CONFIG_SYSTEM => $empty_config_file,
};

ok( $git, "Found git command at $git" );
Expand Down
Loading