For example, i have this simple bash script:
#!/bin/sh
cd $1;
And this cocoa wrapper for it:
NSTask *cd = [[NSTask alloc] init];
NSString *testFolder = [NSString stringWithString:@"/Users/test/Desktop/test 1"];
[cd setLaunchPath:@"/bin/sh"];
[cd setArguments:[NSArray arrayWithObjects:[[NSBundle mainBundle]
pathForResource:@"cd" ofType:@"sh"],testFolder, nil]];
[cd launch];
[cd release];
This is doesn't work correct. And the problem is space in folder name in testFolder.
I'm trying to set testFolder
like this:
NSString *testFolder = [NSString stringWithString:@"/Users/test/Desktop/test\\ 1"]
But this is also output same error:
cd.sh: line 9: cd: /Users/test/Desktop/test: No such file or directory
Paths without spaces (for example: @"/Users/test/Desktop/test1"
) works as well.