TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: JASEN BETTS
from: CHARLES ANGELICH
date: 2003-08-05 06:32:00
subject: getopt()

1237c905323d
c_echo



Hello Jasen - 

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 

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

CA>> I've written code that parses from the _end_ of the CLI
CA>> from whitespace to whitespace with no switch characters
CA>> and noticed no inherent weaknesses (for my purposes). 

JB> ??? "_end_ of the CLI" means what exactly? 

Righthand last char on the CLI (command line interface) or argv
if you prefer. 

CA>> One reason I am asking is that using DOS and Linux plus
CA>> third party binaries it is sometimes difficult to remember
CA>> what the switch character even is. I'm getting old? 

JB> propperly written dos utils should use whatever switch
JB> character dos is configured for... (new versions of dos
JB> from major suppliers have'nt been configurable on this
JB> matter for some time) 

JB> many unix ports will ask for - in the documentation but
JB> recognise / too. 

CA>> The requirement of some binaries to use "-f" preceding
CA>> filenames seems a bit unnecessary and I do often forget.
CA>> TAR and GAWK come to mind. 

JB> there's no requirement for "-f" 

JB> tar cf source.tar Makefile README *.c *.h 

JB> :) 

JB> but seriously the f specifies an optional archive filename
JB> while un-swittched filenames on the command-line specify
JB> files fo put in the archive or extract. 

The order of entry should be sufficient I would think if valid
filenames required more than one character prior to the "."
character.

JB> (IIRC the default archive name for tar is either of tar.out
JB> or /dev/rmt) 

>
>        ,                          ,
>      o/      Charles.Angelich      \o       ,
>       __o/
>     / >          USA, MI           < \   __\__
 

--- * ATP/16bit 2.31 * 
... DOS the Ghost in the Machine! http://www.undercoverdesign.com/dosghost/
* Origin: Try Our Web Based QWK: DOCSPLACE.ORG (1:123/140)
SEEN-BY: 633/267 270
@PATH: 123/140 500 106/2000 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™.