diff --git a/lldb/source/Utility/Args.cpp b/lldb/source/Utility/Args.cpp index 3978f9422653..daccb91d8436 100644 --- a/lldb/source/Utility/Args.cpp +++ b/lldb/source/Utility/Args.cpp @@ -385,6 +385,7 @@ std::string Args::GetShellSafeArgument(const FileSpec &shell, }; static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&;"}, + {ConstString("fish"), " '\"<>()&\\|;"}, {ConstString("tcsh"), " '\"<>()&;"}, {ConstString("zsh"), " '\"<>()&;\\|"}, {ConstString("sh"), " '\"<>()&;"}}; diff --git a/lldb/unittests/Utility/ArgsTest.cpp b/lldb/unittests/Utility/ArgsTest.cpp index 755a110aa555..bc6a3d2c16e4 100644 --- a/lldb/unittests/Utility/ArgsTest.cpp +++ b/lldb/unittests/Utility/ArgsTest.cpp @@ -348,6 +348,13 @@ TEST(ArgsTest, GetShellSafeArgument) { // Normal characters and globbing expressions that shouldn't be escaped. EXPECT_EQ(Args::GetShellSafeArgument(sh, "aA$1*"), "aA$1*"); + // Test escaping fish special characters. + FileSpec fish("/bin/fish", FileSpec::Style::posix); + EXPECT_EQ(Args::GetShellSafeArgument(fish, R"( '"<>()&\|;)"), + R"(\ \'\"\<\>\(\)\&\\\|\;)"); + // Normal characters and expressions that shouldn't be escaped. + EXPECT_EQ(Args::GetShellSafeArgument(fish, "aA$1*"), "aA$1*"); + // Try escaping with an unknown shell. FileSpec unknown_shell("/bin/unknown_shell", FileSpec::Style::posix); EXPECT_EQ(Args::GetShellSafeArgument(unknown_shell, "a'b"), "a\\'b");