[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.12 AutoOpts for Shell Scripts

AutoOpts may be used with shell scripts either 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, or it may 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 to do the parsing:

  1. You cannot obtain options from configuration files.
  2. You cannot obtain options from environment variables.
  3. You cannot save the option state to an option file.
  4. Option conflict/requirement verification is disabled.

Both of these methods are enabled by running AutoGen on the definitions file with the additional main procedure attribute:

main = { main-type = shell-process; };


main = { main-type = shell-parser; };

If you do not supply a proc-to-call, it will default to optionPutShell. That will produce a program that will process the options and generate shell text for the invoking shell to interpret (see section Parsing with an Executable). If you supply the name, optionParseShell, then you will have a program that will generate a shell script that can parse the options (see section Parsing with a Portable Script). If you supply a different procedure name, you will have to provide that routine and it may do whatever you like.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Bruce Korb on August 21, 2015 using texi2html 1.82.