Skip to content

Commit 2cd6a67

Browse files
committed
[lldb] Escape ? for zsh
Previously on macOS with lldb-argdumper if you ran: ``` lldb -o r -- /tmp/foo "some arg?" ``` It would fail with this error: ``` error: shell expansion failed (reason: lldb-argdumper exited with error 1). consider launching with 'process launch'. ``` stderr is silenced here but the underlying error if you print it for debugging is: ``` zsh: no matches found: ? ``` This change escapes the `?` so this argument works as expected.
1 parent 6976dee commit 2cd6a67

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lldb/source/Utility/Args.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ std::string Args::GetShellSafeArgument(const FileSpec &shell,
401401
static ShellDescriptor g_Shells[] = {{"bash", " '\"<>()&;"},
402402
{"fish", " '\"<>()&\\|;"},
403403
{"tcsh", " '\"<>()&;"},
404-
{"zsh", " '\"<>()&;\\|"},
404+
{"zsh", " '\"<>()&;\\|?"},
405405
{"sh", " '\"<>()&;"}};
406406

407407
// safe minimal set

lldb/unittests/Utility/ArgsTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ TEST(ArgsTest, GetShellSafeArgument) {
292292
EXPECT_EQ(Args::GetShellSafeArgument(bash, "a\"b"), "a\\\"b");
293293

294294
FileSpec zsh("/bin/zsh", FileSpec::Style::posix);
295-
EXPECT_EQ(Args::GetShellSafeArgument(zsh, R"('";()<>&|\)"),
296-
R"(\'\"\;\(\)\<\>\&\|\\)");
295+
EXPECT_EQ(Args::GetShellSafeArgument(zsh, R"('"?;()<>&|\)"),
296+
R"(\'\"\?\;\(\)\<\>\&\|\\)");
297297
// Normal characters and expressions that shouldn't be escaped.
298298
EXPECT_EQ(Args::GetShellSafeArgument(zsh, "aA$1*"), "aA$1*");
299299

0 commit comments

Comments
 (0)