diff options
Diffstat (limited to 'glances/secure.py')
-rw-r--r-- | glances/secure.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/glances/secure.py b/glances/secure.py index 65c64945..1bb93a16 100644 --- a/glances/secure.py +++ b/glances/secure.py @@ -11,6 +11,7 @@ from glances.compat import nativestr from subprocess import Popen, PIPE +import re def secure_popen(cmd): @@ -48,8 +49,8 @@ def __secure_popen(cmd): p_last = None # Split by pipe '|' for sub_cmd in cmd.split('|'): - # Split by space ' ' - sub_cmd_split = [i for i in sub_cmd.split(' ') if i] + # Split by space character, but do no split spaces within quotes + sub_cmd_split = [_ for _ in list(filter(None, re.split(r'(\s+)|(".*?"+?)|(\'.*?\'+?)', sub_cmd))) if _ != ' '] p = Popen(sub_cmd_split, shell=False, stdin=sub_cmd_stdin, stdout=PIPE, stderr=PIPE) if p_last is not None: # Allow p_last to receive a SIGPIPE if p exits. |