Skip to content

Instantly share code, notes, and snippets.

@mroch
Created March 5, 2011 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mroch/856303 to your computer and use it in GitHub Desktop.
Save mroch/856303 to your computer and use it in GitHub Desktop.
#import "NSString+BashEscaping.h"
@implementation NSString (NSString_BashEscaping)
- (NSString *)bashString {
NSString *escapedString = [[self
stringByReplacingOccurrencesOfString:@"'" withString:@"'\\''"]
stringByReplacingOccurrencesOfString:@"!" withString:@"\\!"];
return [NSString stringWithFormat:@"'%@'", escapedString];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment