TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: CHARLES ANGELICH
from: andrew clarke
date: 2003-08-06 02:32:02
subject: getopt()

Tue 2003-08-05 06:32, CHARLES ANGELICH (1:123/140) wrote to JASEN BETTS:

 CA>>> I haven't used getopt() for some time now but I have often
 CA>>> wondered what the reasons are that most methods of parsing
 CA>>> the command line want to use switch characters such as "/"
 CA>>> or "-"? 

 JB>> usually to separate switches (ie commands) from filenames
 JB>> or other literals 

 CA> With argc available I don't see the need for the switch chars.
 CA> Order of entry should be sufficient.

Among other things it allows for optional switches, eg.

  touch -t 030806 myfile

It's fairly obvious to anyone accustomed to command line switches will
realise 030806 is the parameter to -t.  On the other hand if you had to use

  touch t 030806 myfile

then you would need to always three arguments.  Plus it's not so obvious
that argv[1] is a switch and that argv[2] is the parameter to argv[2]. 
Someone unfamilar with the touch utility may think that 030806 is a
filename.

'/' is rarely used in UNIX as a switch character because it is a path delimeter.

The whole thing is a bit of a non-issue really...

-- mail{at}ozzmosis.com

--- timEd/FreeBSD 1.11.b1
* Origin: Blizzard of Ozz, Mt Eliza, Melbourne, Australia (3:633/267)
SEEN-BY: 633/267 270
@PATH: 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.