Diff of /Mac/OSX/PythonLauncher/FileSettings.m [c840c5] .. [ca568f]  Maximize  Restore

Repo status: analyzing...

Switch to side-by-side view

--- a/Mac/OSX/PythonLauncher/FileSettings.m
+++ b/Mac/OSX/PythonLauncher/FileSettings.m
@@ -207,7 +207,7 @@
             [NSNumber numberWithBool: inspect], @"inspect",
             [NSNumber numberWithBool: optimize], @"optimize",
             [NSNumber numberWithBool: nosite], @"nosite",
-            [NSNumber numberWithBool: nosite], @"nosite",
+            [NSNumber numberWithBool: tabs], @"tabs",
             others, @"others",
             scriptargs, @"scriptargs",
             [NSNumber numberWithBool: with_terminal], @"with_terminal",
@@ -235,7 +235,7 @@
     if (value) optimize = [value boolValue];
     value = [dict objectForKey: @"nosite"];
     if (value) nosite = [value boolValue];
-    value = [dict objectForKey: @"nosite"];
+    value = [dict objectForKey: @"tabs"];
     if (value) tabs = [value boolValue];
     value = [dict objectForKey: @"others"];
     if (value) others = [value retain];
@@ -245,12 +245,26 @@
     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 *cur_interp = NULL;
+    NSString* script_dir = NULL;
     char hashbangbuf[1024];
     FILE *fp;
     char *p;
+
+    script_dir = [script substringToIndex:
+	    [script length]-[[script lastPathComponent] length]];
     
     if (honourhashbang &&
        (fp=fopen([script cString], "r")) &&
@@ -266,8 +280,9 @@
         cur_interp = interpreter;
         
     return [NSString stringWithFormat:
-        @"\"%@\"%s%s%s%s%s%s %@ \"%@\" %@ %s",
-        cur_interp,
+        @"cd '%@' && '%@'%s%s%s%s%s%s %@ '%@' %@ %s",
+    	[self _replaceSingleQuotes:script_dir],
+        [self _replaceSingleQuotes:cur_interp],
         debug?" -d":"",
         verbose?" -v":"",
         inspect?" -i":"",
@@ -275,7 +290,7 @@
         nosite?" -S":"",
         tabs?" -t":"",
         others,
-        script,
+        [self _replaceSingleQuotes:script],
         scriptargs,
         with_terminal? "&& echo Exit status: $? && exit 1" : " &"];
 }

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks