On Sun, Mar 14, 2010 at 6:42 PM, Kyle Sluder <kyle.slu...@gmail.com> wrote:
> This is incorrect. Unix convention requires the program name be the
> first argument.

Just to clarify, there are a couple reasons for this.

The first is that one can use a single binary to implement more than
one command line program.  Which identity the program adopts is
determined by the value of argv[ 0 ].  If you don't supply argv[ 0 ]
at all, the program may not know what to do.  The identity is supplied
by symbolically linking the extra identities, with the link's name
being the program you want it to act as.

For example, the bash shell has lots of extra features that the
traditional Bourne shell doesn't provide.  But if you execute bash as
/bin/sh, it runs in Bourne-shell compatible mode, and doesn't provide
any of those extra features.

A more extreme example is BusyBox, a single executable which
implements dozens of command-line programs for embedded Linux systems.
 This saves quite a lot of both filesystem and virtual memory space by
providing just one implementation of a lot of common functionality.

The other reason is that some programs use argv[ 0 ] in error
messages, to give the name of the program.  That way you can name the
executable anything you like, and error messages will always be
correct.

Don Quixote
-- 
Don Quixote de la Mancha
quix...@dulcineatech.com
http://www.dulcineatech.com

   Dulcinea Technologies Corporation: Software of Elegance and Beauty.
_______________________________________________

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