https://github.com/MkDev11 created https://github.com/llvm/llvm-project/pull/176076
The 'settings set' command was rejecting values that start with a dash (e.g., 'settings set target.run-args -foo bar') because the option parser was interpreting them as unknown options. This fix inserts '--' before the variable name to terminate option parsing, allowing values like '-foo' to be passed correctly. Fixes #171493 --- Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=94194147 >From fb668aeb47ba86dce5e49aefd63158e57d9bfc6a Mon Sep 17 00:00:00 2001 From: mkdev11 <[email protected]> Date: Thu, 15 Jan 2026 03:47:57 +0200 Subject: [PATCH] [lldb] Fix settings set to accept values starting with dash The 'settings set' command was rejecting values that start with a dash (e.g., 'settings set target.run-args -foo bar') because the option parser was interpreting them as unknown options. This fix inserts '--' before the variable name to terminate option parsing, allowing values like '-foo' to be passed correctly. Fixes #171493 --- lldb/source/Commands/CommandObjectSettings.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index 126f57c738115..fb09a45582126 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -173,6 +173,21 @@ insert-before or insert-after."); CommandReturnObject &result) override { Args cmd_args(command); + // Find the index of the first non-option argument (the variable name). + // Insert "--" before it to prevent values like "-foo" from being + // interpreted as options. + size_t var_name_idx = 0; + for (size_t i = 0; i < cmd_args.GetArgumentCount(); ++i) { + const char *arg = cmd_args.GetArgumentAtIndex(i); + if (arg && arg[0] != '-') { + var_name_idx = i; + break; + } + } + // Insert "--" to terminate option parsing before the variable name and + // its values. + cmd_args.InsertArgumentAtIndex(var_name_idx, "--"); + // Process possible options. if (!ParseOptions(cmd_args, result)) return; _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
