Commit 26cad087 authored by Ronald Oussoren's avatar Ronald Oussoren

This fixes bug #1527397: PythonLauncher runs scripts with the wrong working

directory. It also fixes a bug where PythonLauncher failed to launch scripts
when the scriptname (or the path to the script) contains quotes.
parent 0f53bb1c
...@@ -245,12 +245,26 @@ ...@@ -245,12 +245,26 @@
if (value) with_terminal = [value boolValue]; if (value) with_terminal = [value boolValue];
} }
- (NSString*)_replaceSingleQuotes: (NSString*)string
{
/* Replace all single-quotes by '"'"', that way shellquoting will
* be correct when the result value is delimited using single quotes.
*/
NSArray* components = [string componentsSeparatedByString:@"'"];
return [components componentsJoinedByString:@"'\"'\"'"];
}
- (NSString *)commandLineForScript: (NSString *)script - (NSString *)commandLineForScript: (NSString *)script
{ {
NSString *cur_interp = NULL; NSString *cur_interp = NULL;
NSString* script_dir = NULL;
char hashbangbuf[1024]; char hashbangbuf[1024];
FILE *fp; FILE *fp;
char *p; char *p;
script_dir = [script substringToIndex:
[script length]-[[script lastPathComponent] length]];
if (honourhashbang && if (honourhashbang &&
(fp=fopen([script cString], "r")) && (fp=fopen([script cString], "r")) &&
...@@ -266,8 +280,9 @@ ...@@ -266,8 +280,9 @@
cur_interp = interpreter; cur_interp = interpreter;
return [NSString stringWithFormat: return [NSString stringWithFormat:
@"\"%@\"%s%s%s%s%s%s %@ \"%@\" %@ %s", @"cd '%@' && '%@'%s%s%s%s%s%s %@ '%@' %@ %s",
cur_interp, [self _replaceSingleQuotes:script_dir],
[self _replaceSingleQuotes:cur_interp],
debug?" -d":"", debug?" -d":"",
verbose?" -v":"", verbose?" -v":"",
inspect?" -i":"", inspect?" -i":"",
...@@ -275,7 +290,7 @@ ...@@ -275,7 +290,7 @@
nosite?" -S":"", nosite?" -S":"",
tabs?" -t":"", tabs?" -t":"",
others, others,
script, [self _replaceSingleQuotes:script],
scriptargs, scriptargs,
with_terminal? "&& echo Exit status: $? && exit 1" : " &"]; with_terminal? "&& echo Exit status: $? && exit 1" : " &"];
} }
......
...@@ -185,6 +185,17 @@ Build ...@@ -185,6 +185,17 @@ Build
- Bug #1439538: Drop usage of test -e in configure as it is not portable. - Bug #1439538: Drop usage of test -e in configure as it is not portable.
Mac
---
- PythonLauncher now works correctly when the path to the script contains
characters that are treated specially by the shell (such as quotes).
- Bug #1527397: PythonLauncher now launches scripts with the working directory
set to the directory that contains the script instead of the user home
directory. That latter was an implementation accident and not what users
expect.
What's New in Python 2.5 beta 2? What's New in Python 2.5 beta 2?
================================ ================================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment