[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This will produce a main()
procedure that parses the command line
options and emits to stdout
Bourne shell commands that puts the
option state into environment variables. This can be used within a
shell script as follows:
unset OPTION_CT eval "`opt_parser \"$@\"`" test -z "${OPTION_CT}" && exit 1 test ${OPTION_CT} -gt 0 && shift ${OPTION_CT} |
If the option parsing code detects an error or a request for usage,
it will not emit an assignment to OPTION_CT and the script should just
exit. If the options are set consistently, then something along the
lines of the following will be written to stdout
and evaled:
OPTION_CT=4 export OPTION_CT MYPROG_SECOND='first' export MYPROG_SECOND MYPROG_ANOTHER=1 # 0x1 export MYPROG_ANOTHER |
If the arguments are to be reordered, however, then the resulting set
of operands will be emitted and OPTION_CT
gets set to zero.
For example, the following would be appended to the above:
set -- 'operand1' 'operand2' 'operand3' OPTION_CT=0 |
OPTION_CT
is set to zero since it is not necessary to shift
off any options.
This document was generated by Bruce Korb on September, 30 2006 using texi2html 1.76.