• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTask vs. special characters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask vs. special characters


  • Subject: Re: NSTask vs. special characters
  • From: Pierre Bernard <email@hidden>
  • Date: Mon, 30 Apr 2007 08:18:30 +0200

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSTask vs. special characters
      • From: Rosyna <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>)

  • Prev by Date: Re: Object Hierarchies
  • Next by Date: Re: NSTask vs. special characters
  • Previous by thread: Re: NSTask vs. special characters
  • Next by thread: Re: NSTask vs. special characters
  • Index(es):
    • Date
    • Thread