Skip to content

Commit

Permalink
Support command environment variables on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ferki committed Jan 20, 2025
1 parent 9723777 commit 39f26af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit 39f26af

Please sign in to comment.