diff --git a/ChangeLog b/ChangeLog index 4d874251c..eeea23d51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ Revision history for Rex [API CHANGES] [BUG FIXES] + - Fix switching working directory to another drive [DOCUMENTATION] diff --git a/lib/Rex/Interface/Exec/Local.pm b/lib/Rex/Interface/Exec/Local.pm index cf12a09df..609eef52e 100644 --- a/lib/Rex/Interface/Exec/Local.pm +++ b/lib/Rex/Interface/Exec/Local.pm @@ -12,6 +12,7 @@ our $VERSION = '9999.99.99_99'; # VERSION use Rex::Logger; use Rex::Commands; +use English qw(-no_match_vars); use Symbol 'gensym'; use IPC::Open3; use IO::Select; @@ -49,7 +50,8 @@ sub exec { my ( $out, $err, $pid ); if ( exists $option->{cwd} ) { - $cmd = "cd " . $option->{cwd} . " && $cmd"; + my $cd_cmd = $OSNAME eq 'MSWin32' ? 'cd /d' : 'cd'; + $cmd = "$cd_cmd " . $option->{cwd} . " && $cmd"; } if ( exists $option->{path} ) {