Skip to content

Commit

Permalink
bootstrap: use shlex.split instead of custom implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
kiike committed Nov 5, 2024
1 parent 83b16e9 commit 5ae5cda
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# ignore-tidy-linelength

from __future__ import absolute_import, division, print_function
import shlex
import sys
import os
rust_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -300,23 +301,10 @@ def set(key, value, config):

arr = config

# Split on periods unless the block is quoted.
parts = []
current_part = ''
within_quotes = False
for character in key:
if character in ['"', '\'']:
within_quotes = not within_quotes
elif character == '.' and not within_quotes:
parts.append(current_part)
current_part = ''
else:
current_part += character
else:
if current_part:
parts.append(current_part)
if within_quotes:
raise RuntimeError('end quote not found in arguments.')
# Split `key` on periods using shell semantics.
lexer = shlex.shlex(key, punctuation_chars=True)
lexer.whitespace = "."
parts = list(lexer)

for i, part in enumerate(parts):
if i == len(parts) - 1:
Expand Down

0 comments on commit 5ae5cda

Please sign in to comment.