Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap: add quoting support to avoid splitting #132635

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 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 @@ -288,8 +289,9 @@ def build(known_args):

def set(key, value, config):
if isinstance(value, list):
# Remove empty values, which value.split(',') tends to generate.
value = [v for v in value if v]
# Remove empty values, which value.split(',') tends to generate and
# replace single quotes for double quotes to ensure correct parsing.
value = [v.replace('\'', '"') for v in value if v]

s = "{:20} := {}".format(key, value)
if len(s) < 70 or VERBOSE:
Expand All @@ -298,7 +300,13 @@ def set(key, value, config):
p(s[:70] + " ...")

arr = config
parts = key.split('.')

# Split `key` on periods using shell semantics.
lexer = shlex.shlex(key, posix=True)
lexer.whitespace = "."
lexer.wordchars += "-"
parts = list(lexer)

for i, part in enumerate(parts):
if i == len(parts) - 1:
if is_value_list(part) and isinstance(value, str):
Expand Down
Loading