On Thu, May 21, 2009 at 1:23 AM, Bruce Johnson <bdjohnso...@gmail.com>wrote:

> I have a unix path in an NSString via [[NSBundle bundleForClass: [self
> class]] pathForResource:  etc.. etc..
> The problem is that the path has white spaces scattered in the string.


That's not normally a problem.


> And I need to pass the unix path to a CLI application.  The CLI app
> croaks on the white spaces (for obvious reasons)


The reasons are not at all obvious. Whitespace is only a problem if you type
the whole command as a single string to a shell, which will split the string
on unescaped whitespace to find a command and arguments. Quoted strings are
also not split, so quoting user-provided arguments when they're used in
shell scripts is easier than escaping them.

If you're passing the arguments using NSTask, whitespace is not a problem.
In fact, adding unnecessary quotes and/or escapes to NSTask arguments will
*create* a problem, because NSTask - like everything *except* the command
shell - uses arguments exactly as given, without processing quotes or
escapes.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to