mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
win_shortcut: Support environment variables/UNC paths (#27089)
This was a regression. Integration tests needs to be adapted too.
This commit is contained in:
parent
1c958af88b
commit
91e2319806
1 changed files with 6 additions and 3 deletions
|
@ -26,7 +26,7 @@ $ErrorActionPreference = "Stop"
|
||||||
$params = Parse-Args $args -supports_check_mode $true
|
$params = Parse-Args $args -supports_check_mode $true
|
||||||
$check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -type "bool" -default $false
|
$check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -type "bool" -default $false
|
||||||
|
|
||||||
$src = Get-AnsibleParam -obj $params -name "src"
|
$orig_src = Get-AnsibleParam -obj $params -name "src"
|
||||||
$dest = Get-AnsibleParam -obj $params -name "dest" -type "path" -failifempty $true
|
$dest = Get-AnsibleParam -obj $params -name "dest" -type "path" -failifempty $true
|
||||||
$state = Get-AnsibleParam -obj $params -name "state" -type "string" -default "present" -validateset "absent","present"
|
$state = Get-AnsibleParam -obj $params -name "state" -type "string" -default "present" -validateset "absent","present"
|
||||||
$orig_args = Get-AnsibleParam -obj $params -name "args" -type "string"
|
$orig_args = Get-AnsibleParam -obj $params -name "args" -type "string"
|
||||||
|
@ -39,6 +39,7 @@ $windowstyle = Get-AnsibleParam -obj $params -name "windowstyle" -type "string"
|
||||||
# Expand environment variables on non-path types
|
# Expand environment variables on non-path types
|
||||||
$args = Expand-Environment($orig_args)
|
$args = Expand-Environment($orig_args)
|
||||||
$description = Expand-Environment($orig_description)
|
$description = Expand-Environment($orig_description)
|
||||||
|
$src = Expand-Environment($orig_src)
|
||||||
|
|
||||||
$result = @{
|
$result = @{
|
||||||
changed = $false
|
changed = $false
|
||||||
|
@ -82,8 +83,10 @@ If ($state -eq "absent") {
|
||||||
If (Get-Command -Name $src -Type Application -ErrorAction SilentlyContinue) {
|
If (Get-Command -Name $src -Type Application -ErrorAction SilentlyContinue) {
|
||||||
$src = (Get-Command -Name $src -Type Application).Definition
|
$src = (Get-Command -Name $src -Type Application).Definition
|
||||||
}
|
}
|
||||||
If (-not (Split-Path -Path $src -IsAbsolute)) {
|
If (-not (Test-Path -Path $src -IsValid)) {
|
||||||
Fail-Json -obj $result -message "Source '$src' is not found in PATH and not an absolute path."
|
If (-not (Split-Path -Path $src -IsAbsolute)) {
|
||||||
|
Fail-Json -obj $result -message "Source '$src' is not found in PATH and not a valid or absolute path."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue