#include #import #define BUFFER_SIZE 1<<16 int main(){ NSAutoreleasePool *thePool = [[NSAutoreleasePool alloc] init]; NSTask *myTask; NSPipe *outPipe, *errPipe; NSFileHandle *outHandle, *errHandle; NSString *line; NSMutableArray *args; char buffer[BUFFER_SIZE]; unsigned int smallest_space = 0; while(1){ printf("$ "); if(fgets(buffer, BUFFER_SIZE, stdin)){ buffer[strlen(buffer)-1] = '\0'; line = [NSString stringWithCString:buffer]; args = [NSMutableArray arrayWithArray: [line componentsSeparatedByString:@" "]]; smallest_space = [args indexOfObject:@""]; if (smallest_space != NSNotFound){ NSString *to_rem = [args objectAtIndex:smallest_space]; [args removeObject:to_rem]; } if([args count]==0) continue; if([[args objectAtIndex:0] isEqualToString:@"exit"]) exit(0); myTask = [[NSTask alloc] init]; [myTask release]; } } [thePool release]; return 0; }