From 8938f8daf0d6f4494d7b959599a7a007deda3f7a Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Thu, 14 Feb 2013 03:54:39 +0000 Subject: [PATCH] When launching in the shell, make sure if you specify a relative path, and if the current working directory has a space in it, that we don't hose the shell invocation. Currently if we launch with a relative path, we prepend the current working directory to the PATH using: PATH=`cwd`:$PATH a.out ... We needed to add quotes around the value for PATH to make sure if any paths in PATH contained spaces, that we don't hose the shell command. Now we do a: PATH="`cwd`:$PATH" a.out ... llvm-svn: 175135 --- lldb/source/Target/Process.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 99f4733..d06a184 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -515,7 +515,8 @@ ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell (Error &error, // We have a relative path to our executable which may not work if // we just try to run "a.out" (without it being converted to "./a.out") const char *working_dir = GetWorkingDirectory(); - std::string new_path("PATH="); + // Be sure to put quotes around PATH's value in case any paths have spaces... + std::string new_path("PATH=\""); const size_t empty_path_len = new_path.size(); if (working_dir && working_dir[0]) @@ -536,7 +537,7 @@ ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell (Error &error, new_path += ':'; new_path += curr_path; } - new_path += ' '; + new_path += "\" "; shell_command.PutCString(new_path.c_str()); } -- 2.7.4