Re: "-exec ..." in NSTask ?
Re: "-exec ..." in NSTask ?
- Subject: Re: "-exec ..." in NSTask ?
- From: Chris Ridd <email@hidden>
- Date: Sat, 14 Jun 2003 08:30:41 +0100
On 13/6/03 3:19 pm, Mark Dalrymple <email@hidden> wrote:
>
Hi Zeno,
>
>
> (in reality I'll need to execute something more complex:
>
< find . -name *.java -exec javac -target 1.1 -classpath
>
> "/Applications/MIDP4OSX/classes":. \{} \;
>
> but that DOESN'T MATTER: if I'm able to do the above, I'll be able to
>
solve
>
> my problem)
>
>
For complex commands like that, particularly ones with high overhead
>
(like find groveling through the file system), I use NSTask to start a
>
shell, and feed the shell the command to run with the -c flag. It
>
makes the arguments array a lot simpler and easier to maintain:
It does... until the string being fed in contains a shell-special character
at which point you've got a security hole (worst case scenario), and at best
you've got a non-functioning program.
It is much easier and safer to send the arguments as an array than to try
and add all the escaping necessary to stop sh from blowing up!
Cheers,
Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.