win_shell - fix space escaping for custom executable (#57455)

This commit is contained in:
Jordan Borean 2019-06-17 05:14:58 +10:00 committed by GitHub
parent 0f2903780b
commit d0c4914469
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 3 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- win_shell - Fix bug when setting ``args.executable`` to a pace with a space

View file

@ -93,7 +93,7 @@ Else {
$exec_args = "/c $raw_command_line" $exec_args = "/c $raw_command_line"
} }
$command = "$exec_application $exec_args" $command = "`"$exec_application`" $exec_args"
$run_command_arg = @{ $run_command_arg = @{
command = $command command = $command
} }

View file

@ -269,7 +269,7 @@
- no_profile is changed - no_profile is changed
- no_profile.cmd == "[System.Environment]::CommandLine" - no_profile.cmd == "[System.Environment]::CommandLine"
- no_profile.rc == 0 - no_profile.rc == 0
- no_profile.stdout is match ('^powershell.exe -noninteractive -encodedcommand') - no_profile.stdout is match ('^"powershell.exe" -noninteractive -encodedcommand')
- name: execute powershell with no_profile - name: execute powershell with no_profile
win_shell: '[System.Environment]::CommandLine' win_shell: '[System.Environment]::CommandLine'
@ -284,4 +284,33 @@
- no_profile is changed - no_profile is changed
- no_profile.cmd == "[System.Environment]::CommandLine" - no_profile.cmd == "[System.Environment]::CommandLine"
- no_profile.rc == 0 - no_profile.rc == 0
- no_profile.stdout is match ('^powershell.exe -noprofile -noninteractive -encodedcommand') - no_profile.stdout is match ('^"powershell.exe" -noprofile -noninteractive -encodedcommand')
- name: create symbolic link with space in the path
win_command: cmd.exe /c mklink /d "C:\ansible test link" C:\Windows\System32\WindowsPowerShell\v1.0
args:
creates: C:\ansible test link
- block:
- name: run with space in the executable path
win_shell: '[System.Environment]::CommandLine'
args:
executable: C:\ansible test link\powershell
register: space_exe
- debug:
var: space_exe.stdout|trim
- name: assert run with space in the executable path
assert:
that:
- space_exe is successful
- space_exe is changed
- space_exe.cmd == '[System.Environment]::CommandLine'
- space_exe.rc == 0
- space_exe.stdout|trim == '"C:\\ansible test link\\powershell.exe" /c [System.Environment]::CommandLine'
always:
- name: remove test symbolic link
win_file:
path: C:\ansible test link
state: absent