mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Use --version to see if less can be executed
(less) 2> /dev/null would fail if stdin is /dev/null. Sinceless --version do not read anything from stdin, it is perfect for seeing if the software exist or not. Also replace the whole os system detection by directly using subprocess ( as we use it elsewhere, we already depend on it ).
This commit is contained in:
@@ -71,7 +71,7 @@ def pager(text):
|
|||||||
pager_print(text)
|
pager_print(text)
|
||||||
else:
|
else:
|
||||||
pager_pipe(text, os.environ['PAGER'])
|
pager_pipe(text, os.environ['PAGER'])
|
||||||
elif hasattr(os, 'system') and os.system('(less) 2> /dev/null') == 0:
|
elif subprocess.call('(less --version) 2> /dev/null', shell = True) == 0:
|
||||||
pager_pipe(text, 'less')
|
pager_pipe(text, 'less')
|
||||||
else:
|
else:
|
||||||
pager_print(text)
|
pager_print(text)
|
||||||
|
|||||||
Reference in New Issue
Block a user