This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGc197cddb16b3: [lldb] Add support for escaping zsh arguments (authored by teemperor). Herald added a subscriber: lldb-commits.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104627/new/ https://reviews.llvm.org/D104627 Files: lldb/source/Utility/Args.cpp lldb/unittests/Utility/ArgsTest.cpp Index: lldb/unittests/Utility/ArgsTest.cpp =================================================================== --- lldb/unittests/Utility/ArgsTest.cpp +++ lldb/unittests/Utility/ArgsTest.cpp @@ -322,6 +322,12 @@ EXPECT_EQ(Args::GetShellSafeArgument(bash, "a\""), "a\\\""); EXPECT_EQ(Args::GetShellSafeArgument(bash, "a\"b"), "a\\\"b"); + FileSpec zsh("/bin/zsh", FileSpec::Style::posix); + EXPECT_EQ(Args::GetShellSafeArgument(zsh, R"('";()<>&|\)"), + R"(\'\"\;\(\)\<\>\&\|\\)"); + // Normal characters and expressions that shouldn't be escaped. + EXPECT_EQ(Args::GetShellSafeArgument(zsh, "aA$1*"), "aA$1*"); + // String that doesn't need to be escaped EXPECT_EQ(Args::GetShellSafeArgument(bash, "a"), "a"); Index: lldb/source/Utility/Args.cpp =================================================================== --- lldb/source/Utility/Args.cpp +++ lldb/source/Utility/Args.cpp @@ -386,6 +386,7 @@ static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&"}, {ConstString("tcsh"), " '\"<>()&$"}, + {ConstString("zsh"), " '\"<>()&;\\|"}, {ConstString("sh"), " '\"<>()&"}}; // safe minimal set
Index: lldb/unittests/Utility/ArgsTest.cpp =================================================================== --- lldb/unittests/Utility/ArgsTest.cpp +++ lldb/unittests/Utility/ArgsTest.cpp @@ -322,6 +322,12 @@ EXPECT_EQ(Args::GetShellSafeArgument(bash, "a\""), "a\\\""); EXPECT_EQ(Args::GetShellSafeArgument(bash, "a\"b"), "a\\\"b"); + FileSpec zsh("/bin/zsh", FileSpec::Style::posix); + EXPECT_EQ(Args::GetShellSafeArgument(zsh, R"('";()<>&|\)"), + R"(\'\"\;\(\)\<\>\&\|\\)"); + // Normal characters and expressions that shouldn't be escaped. + EXPECT_EQ(Args::GetShellSafeArgument(zsh, "aA$1*"), "aA$1*"); + // String that doesn't need to be escaped EXPECT_EQ(Args::GetShellSafeArgument(bash, "a"), "a"); Index: lldb/source/Utility/Args.cpp =================================================================== --- lldb/source/Utility/Args.cpp +++ lldb/source/Utility/Args.cpp @@ -386,6 +386,7 @@ static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&"}, {ConstString("tcsh"), " '\"<>()&$"}, + {ConstString("zsh"), " '\"<>()&;\\|"}, {ConstString("sh"), " '\"<>()&"}}; // safe minimal set
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits