Skip to content

Commit fe04396

Browse files
committed
bootstrap: use shlex.split instead of custom implementation
1 parent 83b16e9 commit fe04396

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

src/bootstrap/configure.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# ignore-tidy-linelength
44

55
from __future__ import absolute_import, division, print_function
6+
import shlex
67
import sys
78
import os
89
rust_dir = os.path.dirname(os.path.abspath(__file__))
@@ -300,23 +301,11 @@ 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, posix=True)
306+
lexer.whitespace = "."
307+
lexer.wordchars += "-"
308+
parts = list(lexer)
320309

321310
for i, part in enumerate(parts):
322311
if i == len(parts) - 1:

0 commit comments

Comments
 (0)