aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPStringAdditions.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-11-21 21:25:38 +0000
committerBibiko <bibiko@eva.mpg.de>2010-11-21 21:25:38 +0000
commit20c836954dce8f0d07788003b44e44990ac3a29d (patch)
treebae269bdf7fdd1082ac64f1582c5aecb7dac88f5 /Source/SPStringAdditions.m
parent79bf97de1dc30afb75a07958ff99b6f95473383e (diff)
downloadsequelpro-20c836954dce8f0d07788003b44e44990ac3a29d.tar.gz
sequelpro-20c836954dce8f0d07788003b44e44990ac3a29d.tar.bz2
sequelpro-20c836954dce8f0d07788003b44e44990ac3a29d.zip
• run a normal bash script without #! first line as /bin/sh file whereby stdout is redirected
Diffstat (limited to 'Source/SPStringAdditions.m')
-rw-r--r--Source/SPStringAdditions.m17
1 files changed, 12 insertions, 5 deletions
diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m
index 09f37866..be91fa0b 100644
--- a/Source/SPStringAdditions.m
+++ b/Source/SPStringAdditions.m
@@ -452,7 +452,17 @@
NSBeep();
NSLog(@"Couldn't write script file.");
}
-
+ }
+ } else {
+ [scriptHeaderArguments addObject:@"/bin/sh"];
+ NSError *writeError = nil;
+ [self writeToFile:scriptFilePath atomically:YES encoding:NSUTF8StringEncoding error:writeError];
+ if(writeError == nil) {
+ redirectForScript = YES;
+ [scriptHeaderArguments addObject:scriptFilePath];
+ } else {
+ NSBeep();
+ NSLog(@"Couldn't write script file.");
}
}
@@ -491,10 +501,7 @@
[bashTask setCurrentDirectoryPath:[shellEnvironment objectForKey:@"SP_BUNDLE_PATH"]];
// STDOUT will be redirected to /tmp/SP_BUNDLE_OUTPUT_FILE in order to avoid nasty pipe programming due to block size reading
- if(redirectForScript)
- [bashTask setArguments:[NSArray arrayWithObjects:@"-c", [NSString stringWithFormat:@"%@ > %@", [scriptHeaderArguments componentsJoinedByString:@" "], stdoutFilePath], nil]];
- else
- [bashTask setArguments:[NSArray arrayWithObjects:@"-c", [NSString stringWithFormat:@"%@ > %@", self, stdoutFilePath], nil]];
+ [bashTask setArguments:[NSArray arrayWithObjects:@"-c", [NSString stringWithFormat:@"%@ > %@", [scriptHeaderArguments componentsJoinedByString:@" "], stdoutFilePath], nil]];
NSPipe *stderr_pipe = [NSPipe pipe];
[bashTask setStandardError:stderr_pipe];