From e506b5da14c5a73eff5f9fa79f49dc86848b41f6 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 2 May 2017 14:01:57 -0400 Subject: [PATCH] only set executable from shell if not set already --- lib/ansible/module_utils/basic.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 0de60487419..ac10d61294e 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -2315,7 +2315,7 @@ class AnsibleModule(object): if isinstance(args, list): if use_unsafe_shell: - args = " ".join([pipes.quote(x) for x in args]) + args = " ".join([shlex_quote(x) for x in args]) shell = True elif isinstance(args, (binary_type, text_type)) and use_unsafe_shell: shell = True @@ -2334,7 +2334,8 @@ class AnsibleModule(object): shell = False if use_unsafe_shell: - executable = os.environ.get('SHELL') + if executable is None: + executable = os.environ.get('SHELL') if executable: args = [executable, '-c', args] else: