[lldb] Expand $ when using tcsh

Unlike for any of the other shells, we were escaping $ when using tcsh.
There's nothing special about $ in tcsh and this prevents you from
expanding shell variables, one of the main reasons this functionality
exists in the first place.

Differential revision: https://reviews.llvm.org/D123690
This commit is contained in:
Jonas Devlieghere 2022-04-13 09:42:56 -07:00
parent 2f98c5febc
commit acc56e55fe
No known key found for this signature in database
GPG Key ID: 49CC0BD90FDEED4D
4 changed files with 17 additions and 3 deletions

View File

@ -385,7 +385,7 @@ std::string Args::GetShellSafeArgument(const FileSpec &shell,
};
static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&;"},
{ConstString("tcsh"), " '\"<>()&$;"},
{ConstString("tcsh"), " '\"<>()&;"},
{ConstString("zsh"), " '\"<>()&;\\|"},
{ConstString("sh"), " '\"<>()&;"}};

View File

@ -0,0 +1,6 @@
#include <stdio.h>
int main(int argc, char **argv) {
for (int i = 0; i < argc; ++i)
printf("%s\n", argv[i]);
}

View File

@ -0,0 +1,8 @@
REQUIRES: shell, system-darwin
RUN: %clang_host %p/Inputs/echo.c -o %t.out
RUN: not %lldb %t.out -b -o 'process launch --shell=tcsh -- $NO_SUCH_SHELL_VARIABLE' 2>&1 | FileCheck --check-prefix=FAILURE %s
RUN: %lldb %t.out -b -o 'process launch --shell=tcsh -- $HOME' 2>&1 | FileCheck --check-prefix=SUCCESS %s
FAILURE: exited with status 1
SUCCESS: exited with status = 0

View File

@ -336,8 +336,8 @@ TEST(ArgsTest, GetShellSafeArgument) {
// Test escaping tcsh special characters.
FileSpec tcsh("/bin/tcsh", FileSpec::Style::posix);
EXPECT_EQ(Args::GetShellSafeArgument(tcsh, R"( '"<>()&$;)"),
R"(\ \'\"\<\>\(\)\&\$\;)");
EXPECT_EQ(Args::GetShellSafeArgument(tcsh, R"( '"<>()&;)"),
R"(\ \'\"\<\>\(\)\&\;)");
// Normal characters and globbing expressions that shouldn't be escaped.
EXPECT_EQ(Args::GetShellSafeArgument(tcsh, "aA1*"), "aA1*");