summaryrefslogtreecommitdiffstats
path: root/lib/ansible/plugins/shell
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:55:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:55:42 +0000
commit62d9962ec7d01c95bf5732169320d3857a41446e (patch)
treef60d8fc63ff738e5f5afec48a84cf41480ee1315 /lib/ansible/plugins/shell
parentReleasing progress-linux version 2.14.13-1~progress7.99u1. (diff)
downloadansible-core-62d9962ec7d01c95bf5732169320d3857a41446e.tar.xz
ansible-core-62d9962ec7d01c95bf5732169320d3857a41446e.zip
Merging upstream version 2.16.5.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/ansible/plugins/shell')
-rw-r--r--lib/ansible/plugins/shell/__init__.py5
-rw-r--r--lib/ansible/plugins/shell/cmd.py14
-rw-r--r--lib/ansible/plugins/shell/powershell.py2
3 files changed, 11 insertions, 10 deletions
diff --git a/lib/ansible/plugins/shell/__init__.py b/lib/ansible/plugins/shell/__init__.py
index d5db261..c9f8add 100644
--- a/lib/ansible/plugins/shell/__init__.py
+++ b/lib/ansible/plugins/shell/__init__.py
@@ -24,10 +24,11 @@ import re
import shlex
import time
+from collections.abc import Mapping, Sequence
+
from ansible.errors import AnsibleError
-from ansible.module_utils._text import to_native
+from ansible.module_utils.common.text.converters import to_native
from ansible.module_utils.six import text_type, string_types
-from ansible.module_utils.common._collections_compat import Mapping, Sequence
from ansible.plugins import AnsiblePlugin
_USER_HOME_PATH_RE = re.compile(r'^~[_.A-Za-z0-9][-_.A-Za-z0-9]*$')
diff --git a/lib/ansible/plugins/shell/cmd.py b/lib/ansible/plugins/shell/cmd.py
index c1083dc..152fdd0 100644
--- a/lib/ansible/plugins/shell/cmd.py
+++ b/lib/ansible/plugins/shell/cmd.py
@@ -34,24 +34,24 @@ class ShellModule(PSShellModule):
# Used by various parts of Ansible to do Windows specific changes
_IS_WINDOWS = True
- def quote(self, s):
+ def quote(self, cmd):
# cmd does not support single quotes that the shlex_quote uses. We need to override the quoting behaviour to
# better match cmd.exe.
# https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
# Return an empty argument
- if not s:
+ if not cmd:
return '""'
- if _find_unsafe(s) is None:
- return s
+ if _find_unsafe(cmd) is None:
+ return cmd
# Escape the metachars as we are quoting the string to stop cmd from interpreting that metachar. For example
# 'file &whoami.exe' would result in 'file $(whoami.exe)' instead of the literal string
# https://stackoverflow.com/questions/3411771/multiple-character-replace-with-python
for c in '^()%!"<>&|': # '^' must be the first char that we scan and replace
- if c in s:
+ if c in cmd:
# I can't find any docs that explicitly say this but to escape ", it needs to be prefixed with \^.
- s = s.replace(c, ("\\^" if c == '"' else "^") + c)
+ cmd = cmd.replace(c, ("\\^" if c == '"' else "^") + c)
- return '^"' + s + '^"'
+ return '^"' + cmd + '^"'
diff --git a/lib/ansible/plugins/shell/powershell.py b/lib/ansible/plugins/shell/powershell.py
index de5e705..f2e78cb 100644
--- a/lib/ansible/plugins/shell/powershell.py
+++ b/lib/ansible/plugins/shell/powershell.py
@@ -23,7 +23,7 @@ import pkgutil
import xml.etree.ElementTree as ET
import ntpath
-from ansible.module_utils._text import to_bytes, to_text
+from ansible.module_utils.common.text.converters import to_bytes, to_text
from ansible.plugins.shell import ShellBase