Revision [347]

This is an old revision of CommandXgetopts made by DavidLee on 2009-01-03 06:55:37.

 

xgetopts optstring [args]


xgetopts runs the internal shell command option processor (Options) and omits the result as an XML document.
This is useful to be able to parse arguments from within shell scripts in a form similar to internal commands.


optstring A string containing the allowed options seperated by "," described below
args 0 or more arguments to be parsed using the optstring, typically $*


optstring


optstring is a single string describing the available options. It take the form of option_def "," option_def ...
Each "option_def" is the option name, optionally followed by "=longname" optionally followed by ":" or ":+".

If "=longname" is used then "longname" is an alias for the option.
If the option is followed by ":" the the option requires a value which is taken from the next argument.
If the option is followed by ":+" then the option can be specified multiple times and a list of values is produced.

Example


%%
$ xgetopts "a=all,b:,c:+" -all -c c1 -c c2 arg1 arg2
<xgetopts>
<options>
<option name="a"/>
<option name="c">
<value>c1</value>
<value>c2</value>
</option>
</options>
<args>
<arg>arg1</arg>
<arg>arg2</arg>
</args>
</xgetopts>


There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki