Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 7a18271

Browse files
committed
Don't support comments in parsed parameters
Until now, when virtinst was parsing parameters, '#' were used as starts of a comment, '\' as escape strings etc. due to the use of shlex. The use of '\' is predictable (e.g. filename with a ',' in it), but the '#' is usually escaped in shell only. Also, even when not escaped, shlex is not fully compatible with some syntax rules for parsing '#'. For example '#' in 'echo asdf#fdsa' will not be used as a comment in bash (there is no whitespace in front of the '#'), but in our '--disk name#something.img' (parsed using shlex), it will be used as a comment even though it is not expected from the user. Removing '#' (the only character) from shlex.commenters disables all similar comments, which is desired as users won't be trying to use comments to comment out parts of parameters.
1 parent 7a18b87 commit 7a18271

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

virtinst/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Utility functions for the command line drivers
33
#
4-
# Copyright 2006-2007 Red Hat, Inc.
4+
# Copyright 2006-2007, 2013 Red Hat, Inc.
55
# Jeremy Katz <katzj@redhat.com>
66
#
77
# This program is free software; you can redistribute it and/or modify
@@ -1186,6 +1186,7 @@ def parse_optstr_tuples(optstr, compress_first=False):
11861186
return [(optstr, None)]
11871187

11881188
argsplitter = shlex.shlex(optstr, posix=True)
1189+
argsplitter.commenters = ""
11891190
argsplitter.whitespace = ","
11901191
argsplitter.whitespace_split = True
11911192

0 commit comments

Comments
 (0)