[Lldb-commits] [lldb] r175135 - <rdar://problem/13200878>

Greg Clayton gclayton at apple.com
Wed Feb 13 19:54:39 PST 2013


Author: gclayton
Date: Wed Feb 13 21:54:39 2013
New Revision: 175135

URL: http://llvm.org/viewvc/llvm-project?rev=175135&view=rev
Log:
<rdar://problem/13200878>

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 ...



Modified:
    lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=175135&r1=175134&r2=175135&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Wed Feb 13 21:54:39 2013
@@ -515,7 +515,8 @@ ProcessLaunchInfo::ConvertArgumentsForLa
                     // 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::ConvertArgumentsForLa
                             new_path += ':';
                         new_path += curr_path;
                     }
-                    new_path += ' ';
+                    new_path += "\" ";
                     shell_command.PutCString(new_path.c_str());
                 }
 





More information about the lldb-commits mailing list