vmtest.vm: quote command arguments from CLI

This fixes commands like `python3 -m vmtest.vm python3 -c 'foo; bar'`.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
This commit is contained in:
Omar Sandoval 2023-10-25 10:07:14 -07:00
parent 5a8bf55652
commit 219a819659

View File

@ -400,7 +400,11 @@ if __name__ == "__main__":
args.root_directory = None
try:
command = " ".join(args.command) if args.command else "sh -i"
command = (
" ".join([shlex.quote(arg) for arg in args.command])
if args.command
else "sh -i"
)
sys.exit(run_in_vm(command, kernel, args.root_directory, args.directory))
except LostVMError as e:
print("error:", e, file=sys.stderr)