MSYS2: Test commands in pipes need quoting

At least using MSYS2 python (that uses system() that uses CMD.EXE)
we must quote every command in a pipe, otherwise the "'C:' is not
recognized as an internal or external program" error occurs.
This commit is contained in:
João Valverde 2021-09-25 05:39:55 +01:00 committed by Wireshark GitLab Utility
parent ef06593c13
commit 481d0716e5
1 changed files with 8 additions and 3 deletions

View File

@ -70,10 +70,13 @@ def wireshark_k(wireshark_command):
return tuple(list(wireshark_command) + ['-k'])
def capture_command(*cmd_args, shell=False):
def capture_command(*args, shell=False):
cmd_args = list(args)
if type(cmd_args[0]) != str:
# Assume something like ['wireshark', '-k']
cmd_args = list(cmd_args[0]) + list(cmd_args)[1:]
if sys.platform == "win32":
cmd_args[0] = '"{}"'.format(cmd_args[0])
if shell:
cmd_args = ' '.join(cmd_args)
return cmd_args
@ -243,7 +246,8 @@ def check_dumpcap_autostop_stdin(cmd_dumpcap):
elif filesize is not None:
condition = 'filesize:{}'.format(filesize)
capture_cmd = ' '.join((cmd_dumpcap,
cmd_ = '"{}"'.format(cmd_dumpcap)
capture_cmd = ' '.join((cmd_,
'-i', '-',
'-w', testout_file,
'-a', condition,
@ -277,7 +281,8 @@ def check_dumpcap_ringbuffer_stdin(cmd_dumpcap):
elif filesize is not None:
condition = 'filesize:{}'.format(filesize)
capture_cmd = ' '.join((cmd_dumpcap,
cmd_ = '"{}"'.format(cmd_dumpcap)
capture_cmd = ' '.join((cmd_,
'-i', '-',
'-w', testout_file,
'-a', 'files:2',