33# ignore-tidy-linelength
44
55from __future__ import absolute_import , division , print_function
6+ import shlex
67import sys
78import os
89rust_dir = os .path .dirname (os .path .abspath (__file__ ))
@@ -290,7 +291,7 @@ def set(key, value, config):
290291 if isinstance (value , list ):
291292 # Remove empty values, which value.split(',') tends to generate and
292293 # replace single quotes for double quotes to ensure correct parsing.
293- value = [v . replace ( ' \' ' , '"' ) for v in value if v ]
294+ value = [v for v in value if v ]
294295
295296 s = "{:20} := {}" .format (key , value )
296297 if len (s ) < 70 or VERBOSE :
@@ -300,23 +301,10 @@ def set(key, value, config):
300301
301302 arr = config
302303
303- # Split on periods unless the block is quoted.
304- parts = []
305- current_part = ''
306- within_quotes = False
307- for character in key :
308- if character in ['"' , '\' ' ]:
309- within_quotes = not within_quotes
310- elif character == '.' and not within_quotes :
311- parts .append (current_part )
312- current_part = ''
313- else :
314- current_part += character
315- else :
316- if current_part :
317- parts .append (current_part )
318- if within_quotes :
319- raise RuntimeError ('end quote not found in arguments.' )
304+ # Split `key` on periods using shell semantics.
305+ lexer = shlex .shlex (key , punctuation_chars = True , posix = True )
306+ lexer .whitespace = "."
307+ parts = list (lexer )
320308
321309 for i , part in enumerate (parts ):
322310 if i == len (parts ) - 1 :
0 commit comments