mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-04 23:39:09 -07:00
Preserve exit code in winrm exec (#20166)
Raw winrm exec discards the exit code from external processes- this change preserves the exit code if present.
This commit is contained in:
parent
af96cba7e1
commit
b773ae4291
2 changed files with 8 additions and 4 deletions
|
@ -352,7 +352,7 @@ class Connection(ConnectionBase):
|
|||
'''
|
||||
|
||||
script = script_template.format(self._shell._escape(out_path))
|
||||
cmd_parts = self._shell._encode_script(script, as_list=True, strict_mode=False)
|
||||
cmd_parts = self._shell._encode_script(script, as_list=True, strict_mode=False, preserve_rc=False)
|
||||
|
||||
result = self._winrm_exec(cmd_parts[0], cmd_parts[1:], stdin_iterator=self._put_file_stdin_iterator(in_path, out_path))
|
||||
# TODO: improve error handling
|
||||
|
@ -404,7 +404,7 @@ class Connection(ConnectionBase):
|
|||
}
|
||||
''' % dict(buffer_size=buffer_size, path=self._shell._escape(in_path), offset=offset)
|
||||
display.vvvvv('WINRM FETCH "%s" to "%s" (offset=%d)' % (in_path, out_path, offset), host=self._winrm_host)
|
||||
cmd_parts = self._shell._encode_script(script, as_list=True)
|
||||
cmd_parts = self._shell._encode_script(script, as_list=True, preserve_rc=False)
|
||||
result = self._winrm_exec(cmd_parts[0], cmd_parts[1:])
|
||||
if result.status_code != 0:
|
||||
raise IOError(to_native(result.std_err))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue