On Sat, 6 Feb 2010 17:41:35 -0800 Eric Peterson wrote:
> I am looking to use long options in some of my code instead of single
> value switches.  I read the getopt shouldn't be used, instead getopts
> (with an 's') which is built in to ksh93.  Looking at the example in
> appendix B of a the  book _Learning the Korn Shell_, I made the
> following test case.

> * Should I just give up on getopts and roll my own? (.e.g -d would not be 
> allowed, but --date and --delay would be)

> I see that I can't use two long options that start with the same letter (e.g. 
> --date and --delay), since both would be reduced to "-d" for getopts.

that is incorrect
the form is
        [<flag>:<long-name-1>|<long-name-2>...]
each long option needs either a flag character or a 2 or more digit number
so you could have
        [d:date?...]
        [D:delay?...]

>   * I do like how this makes a nice man page (e.g ./test.ksh --man).

and --html

>     But is it possible to have only long options without short options?

if you just want long options and no flags (or if you run out of single letters 
like ls(1))
        [10:date?...]
        [11:delay?...]

>   * Is there a way to make some of these options required and some
>     optional, without checking after getopts?  i.e.,within the usage
>     definitions.  I see where I can make an OPTARG optional (e.g.
>     USAGE+="[r:read?reader mode.]:?[reader]"

"required option" is an oxymoron, no?
if some command line argument is required, make it a required operand, not an 
option

_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to