powershell: Respect remote_tmp path set by the user (#40210)

* powershell: Respect remote_tmp path set by the user

* Fixed up linting error and typo

* Added changelog
This commit is contained in:
Jordan Borean 2018-05-23 07:12:32 +10:00 committed by GitHub
parent 070a5557d1
commit f84f3de7c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 281 additions and 203 deletions

View file

@ -335,7 +335,25 @@ Function Load-CommandUtils {
# [Ansible.CommandUtil]::RunCommand(string lpApplicationName, string lpCommandLine, string lpCurrentDirectory, string stdinInput, string environmentBlock)
#
# there are also numerous P/Invoke methods that can be called if you are feeling adventurous
# FUTURE: find a better way to get the _ansible_remote_tmp variable
$original_tmp = $env:TMP
$original_temp = $env:TEMP
$remote_tmp = $original_tmp
$module_params = Get-Variable -Name complex_args -ErrorAction SilentlyContinue
if ($module_params) {
if ($module_params.Value.ContainsKey("_ansible_remote_tmp") ) {
$remote_tmp = $module_params.Value["_ansible_remote_tmp"]
$remote_tmp = [System.Environment]::ExpandEnvironmentVariables($remote_tmp)
}
}
$env:TMP = $remote_tmp
$env:TEMP = $remote_tmp
Add-Type -TypeDefinition $process_util
$env:TMP = $original_tmp
$env:TEMP = $original_temp
}
Function Get-ExecutablePath($executable, $directory) {