diff --git a/Slate/ShellOperation.m b/Slate/ShellOperation.m index d73d4f19..35a45cbb 100644 --- a/Slate/ShellOperation.m +++ b/Slate/ShellOperation.m @@ -133,7 +133,7 @@ + (id)shellOperationFromString:(NSString *)shellOperation { } NSString *commandAndArgs = [tokens lastObject]; NSMutableArray *commandAndArgsTokens = [NSMutableArray array]; - [StringTokenizer tokenize:commandAndArgs into:commandAndArgsTokens]; + [StringTokenizer tokenize:commandAndArgs into:commandAndArgsTokens quoteChars:[NSCharacterSet characterSetWithCharactersInString:QUOTES]]; if ([commandAndArgsTokens count] < 1) { SlateLogger(@"ERROR: Invalid Parameters '%@'", shellOperation); @throw([NSException exceptionWithName:@"Invalid Parameters" reason:[NSString stringWithFormat:@"Invalid Parameters in '%@'. Shell operations require the following format: shell [wait] 'command'", shellOperation] userInfo:nil]); diff --git a/SlateTests/TestShellUtils.m b/SlateTests/TestShellUtils.m index ce5f008e..99d47351 100644 --- a/SlateTests/TestShellUtils.m +++ b/SlateTests/TestShellUtils.m @@ -20,6 +20,7 @@ #import "TestShellUtils.h" #import "ShellUtils.h" +#import "ShellOperation.h" @implementation TestShellUtils @@ -53,4 +54,11 @@ - (void)testRunWithQuotedArgs { STAssertEquals(found, 1, @"Result should include all strings"); } +-(void)testShellOperationFromStringWithQuotesAndSpaces { + id operation = [ShellOperation shellOperationFromString:@"shell '/usr/bin/open -a \"Sublime Text\"'"]; + int argumentCount = [[operation args] count]; + + STAssertEquals(argumentCount, 2, @"The shell operation must only contain two arguments"); +} + @end