summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Martz <matt@sivel.net>2016-09-09 08:30:37 -0500
committerBrian Coca <bcoca@users.noreply.github.com>2016-09-09 09:30:37 -0400
commiteefe359d6b0d29b5ead94c560c7a6475235899e2 (patch)
treeeeadda79822c76d36414ae3fd55114ab72f897f6
parent1df924e1d55f12f684c835bcd404c89053693022 (diff)
downloadansible-eefe359d6b0d29b5ead94c560c7a6475235899e2.tar.gz
Don't use the shell to catch output, catch output in python. Fixes #17137 (#17449)
-rw-r--r--lib/ansible/cli/__init__.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/ansible/cli/__init__.py b/lib/ansible/cli/__init__.py
index 3176d9c956..48def42ba9 100644
--- a/lib/ansible/cli/__init__.py
+++ b/lib/ansible/cli/__init__.py
@@ -479,10 +479,13 @@ class CLI(object):
display.display(text)
else:
self.pager_pipe(text, os.environ['PAGER'])
- elif subprocess.call('(less --version) &> /dev/null', shell = True) == 0:
- self.pager_pipe(text, 'less')
else:
- display.display(text)
+ p = subprocess.Popen('less --version', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ p.communicate()
+ if p.returncode == 0:
+ self.pager_pipe(text, 'less')
+ else:
+ display.display(text)
@staticmethod
def pager_pipe(text, cmd):