Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask vs. special characters



Hi!

Thanks for your replay.


How did you possibly get this to work? NSTask takes a list of arguments. These arguments do not need to be shell escaped unless your NSTask is a shell (ie, tsch, bash, et cetera). If your NSTask is a shell, that's very, very bad. But you could just enclose the string with quotes if you're doing such a thing.

I think I know where I went wrong. I am using NSTask in 2 different ways. Either like this:


	NSMutableArray *arguments = [NSMutableArray array];
	
	[arguments addObject:@"/usr/bin/zip"];
	[arguments addObject:@"-r"];
	[arguments addObject:file];
	[arguments addObject:@"."];
	
	[self setShellWrapper:[[AMShellWrapper alloc] initWithController:self
														   inputPipe:nil
														  outputPipe:nil
														   errorPipe:nil
													workingDirectory:[self directory]
														 environment:nil
														   arguments:arguments]];

or if things get more complex, I create a shell script file and run that using /bin/sh

I guess in the first use, the "file" argument is OK no matter what characters it contains.

In the shell script file however I am running into trouble.

This above code leaks. And the replacements aren't necessary when not using a shell or quoting things.

Thanks. NSMutableString *string = [[self mutableCopy] autorelease];


Here's the big problem... IIRC, %s interprets the string as the system encoding. (Which would be either MacFrench or MacRoman in your case). But -fileSystemRepresentation returns a "UTF-8" string. So anything that doesn't have the exact same value (such as French accents) in both encodings are going to get changed and mangled and you'll get a file not found error.

Well this is how I got it to work. I actually do want the decomposed characters in my shell script file.


Best,
Pierre

- - -
Houdah Software s. à r. l.
http://www.houdah.com

HoudahGeo: One-stop photo geocoding
HoudahSpot: Powerful Spotlight frontend



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >NSTask vs. special characters (From: Pierre Bernard <email@hidden>)
 >Re: NSTask vs. special characters (From: Pierre Bernard <email@hidden>)
 >Re: NSTask vs. special characters (From: Rosyna <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.