Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /usr/share/doc/autogen/autogen.html/ drwxr-xr-x | |
| Viewing file: Select action/file-type: Next: script-parser, Up: shell options [Contents][Index] 7.12.1 Parsing with an ExecutableThe following commands are approximately all that is needed to build a shell script command line option parser from an option definition file: autogen -L <opt-template-dir> test-errors.def
cc -o test-errors -L <opt-lib-dir> -I <opt-include-dir> \
-DTEST_PROGRAM_OPTS test-errors.c -lopts
The resulting program can then be used within your shell script as follows: eval `./test-errors "$@"`
if [ -z "${OPTION_CT}" ] ; then exit 1 ; fi
test ${OPTION_CT} -gt 0 && shift ${OPTION_CT}
Here is the usage output example from AutoOpts error handling tests. The option definition has argument reordering enabled: test_errors - Test AutoOpts for errors
Usage: errors [ -<flag> [<val>] | --<name>[{=| }<val>] ]... arg ...
Flg Arg Option-Name Description
-o no option The option option descrip
-s Str second The second option descrip
- may appear up to 10 times
-i --- ignored we have dumped this
-X no another Another option descrip
- may appear up to 5 times
-? no help display extended usage information and exit
-! no more-help extended usage information passed thru pager
-> opt save-opts save the option state to a config file
-< Str load-opts load options from a config file
- disabled as '--no-load-opts'
- may appear multiple times
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
Operands and options may be intermixed. They will be reordered.
The following option preset mechanisms are supported:
- reading file errorsRC
Using the invocation, test-errors operand1 -s first operand2 -X -- -s operand3 you get the following output for your shell script to evaluate: OPTION_CT=4 export OPTION_CT TEST_ERRORS_SECOND='first' export TEST_ERRORS_SECOND TEST_ERRORS_ANOTHER=1 # 0x1 export TEST_ERRORS_ANOTHER set -- 'operand1' 'operand2' '-s' 'operand3' OPTION_CT=0 Next: script-parser, Up: shell options [Contents][Index] |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0049 ]-- |