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

1237c94464c2
c_echo



Hello Jasen - 

CA>>>> I haven't used getopt() for some time now but I have
CA>>>> often wondered what the reasons are that most methods of
CA>>>> parsing the command line want to use switch characters
CA>>>> such as "/" 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
CA>> chars. Order of entry should be sufficient. 

JB> for trivial tools it often is. 

To be honest I only write trivial tools, the more trivial the
better. I like to think I'm following in the *nix model of just
piping from one to the other but I detect a good deal of
inertia when even thinking about taking on writing a complete
app with user-interface etc. I'm seriously considering Steve
Gibson's offer of a template for writing Windows apps but it's
all ASM and I would have to install a Windows
compiler/assembler to use it. Getting lazy in my old age. ;-) 

JB> try designing something that can do,everything the dos copy
JB> command can do (well the things it's documented as being
JB> capable of) without it using any switches... 

There are so many clones of "copy" I never thought to write
another one but I have written a dropin replacement for "sort"
in all C code. I could fiddle with that one and see if I could
remove the switch characters as an exercise but since it is
intended to pipe input and output I suspect that would be far
too easy. :-) 

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

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

JB> no, because the archive filename is optional... you don't
JB> need to name it if you're satisfied with the default...
JB> (/dev/rmt0 is the (first) auto-Rewinding Magnetic Tape
JB> drive...) 

You're right, I might run into trouble trying to allow for a
default filename. 

JB> with AWK you can put the program on the command-line
JB> instead of using -f 

Yes, I use AWK occasionally and like it (recently downloaded
Kernighan's W95 executable for AWK) but putting the code into
the command line is somewhat tedious (for me) with the need to
escape characters etc. Starts to look like PERL code eventually
and I don't like PERL. :-) 

>
>        ,                          ,
>      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™.