| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
AutoOpts may be used with shell scripts by automatically creating a complete program that will process command line options and pass back the results to the invoking shell by issuing shell variable assignment commands. It may also be used to generate portable shell code that can be inserted into your script.
The functionality of these features, of course, is somewhat constrained compared with the normal program facilities. Specifically, you cannot invoke callout procedures with either of these methods. Additionally, if you generate a shell script:
Both of these methods are enabled by running AutoGen on the definitions file with the additional global attribute:
test-main [ = proc-to-call ] ; |
If you do not supply a proc-to-call, it will default
to putBourneShell. That will produce a program that
will process the options and generate shell text for the
invoking shell to interpret. If you supply the name,
putShellParse, then you will have a program that
will generate a shell script that can parse the options.
If you supply a different procedure name, you will have to
provide that routine and it may do whatever you like.
In summary, you will need to issue approximately the following two commands to have a working program:
autogen -L <opt-template-dir> program.def
cc -o progopts -L <opt-lib-dir> -I <opt-include-dir> \
-DTEST_program_OPTS program.c -lopts
|
The resulting program can be used within your shell script as follows:
eval `./progopts $@`
if [ -z "${OPTION_CT}" ] ; then exit 1 ; fi
shift ${OPTION_CT}
|
If you had used "test-main = putShellParse" instead, then you can,
at this point, merely run the program and it will write the parsing
script to standard out. You may also provide this program with command
line options to specify the shell script file to create or edit, and you
may specify the shell program to use on the first shell script line.
That program's usage text would look something like this:
genshellopt - Generate Shell Option Processing Script - Ver. 1
USAGE: genshellopt [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
Flg Arg Option-Name Description
-o YES script Output Script File
-s YES shell Shell name (follows "#!" magic)
- disabled as --no-shell
- enabled by default
-v opt version Output version information and exit
-? no help Display usage information and exit
-! no more-help Extended usage information passed thru pager
Options may be specified by doubled hyphens and their name
or by a single hyphen and the flag character (option value).
Note that `shell' is only useful if the output file does not already
exist. If it does, then the shell name and optional first argument
will be extracted from the script file.
If the script file already exists and contains Automated Option Processing
text, the second line of the file through the ending tag will be replaced
by the newly generated text. The first `#!' line will be regenerated.
= = = = = = = =
This incarnation of genshell will produce
a shell script to parse the options for getdefs:
getdefs - AutoGen Definition Extraction Tool - Ver. 1.3
USAGE: getdefs { <option-name>[{=| }<val>] }...
Arg Option-Name Req? Description
YES defs-to-get opt Regexp to look for after the "/*="
opt ordering opt Alphabetize or use named file
Num first-index opt The first index to apply to groups
YES input YES Input file to search for defs
YES subblock opt subblock definition names
YES listattr opt attribute with list of values
opt filelist opt Insert source file names into defs
YES assign opt Global assignments
YES common-assign opt Assignments common to all blocks
YES copy opt File(s) to copy into definitions
opt srcfile opt Insert source file name into each def
opt linenum opt Insert source line number into each def
YES output opt Output file to open
opt autogen opt Invoke AutoGen with defs
YES template opt Template Name
YES agarg opt AutoGen Argument
YES base-name opt Base name for output file(s)
opt version opt Output version information and exit
no help opt Display usage information and exit
no more-help opt Extended usage information passed thru pager
opt save-opts opt Save the option state to an rc file
YES load-opts opt Load options from an rc file
All arguments are named options.
|
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |