2.6 Script arguments handling

Preprocessor Macro: mbfl_command_line_argument (VARNAME, ARGINDEX)
Preprocessor Macro: mbfl_command_line_argument (VARNAME, ARGINDEX, OPTIONS)

Define a variable holding an argument to the script: store in the variable VARNAME the value at key ARGINDEX in the index array ARGV; the first argument has index 0. The optional OPTIONS are options for the shell built–in declare.

Example, the following:

mbfl_command_line_argument(PATHNAME, 3, -r)

is expanded to:

declare -r PATHNAME=${ARGV[3]}
Preprocessor Macro: mbfl_extract_command_line_argument (VARNAME, ARGINDEX)
Preprocessor Macro: mbfl_extract_command_line_argument (VARNAME, ARGINDEX, OPTIONS)

Expand into an equivalent of:

mbfl_command_line_argument(VARNAME, ARGINDEX, OPTIONS)
mbfl_variable_unset(ARGV[ARGINDEX])

We use this macro to access a non–option command line argument and to remove it from the array ARGV, so that it will no longer be included in expansions like:

${ARGV[@]}

This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.