Usually, in a script action function, we want to do this:
function script_action_DO_SOMETHING () { local -r NUMBER_OF_REQUIRED_ARGUMENTS=3 if ! mbfl_wrong_num_args $NUMBER_OF_REQUIRED_ARGUMENTS $ARGC then mbfl_main_print_usage_screen_brief exit_because_wrong_num_args fi ... do something ... }
Validate the number of arguments. REQUIRED is the required number of arguments, PRESENT is the given number of arguments on the command line. If the number of arguments is different from the required one: print an error message and return with code one; else return with code zero.
Validate the number of arguments. ARGC must be between MIN_REQUIRED and MAX_REQUIRED, inclusive.
If the ARGC
global variable is set to zero: fills the global variable ARGV
with lines
read from stdin. If the global variable mbfl_option_NULL
is set to yes
: lines are
read using the null character as terminator, else they are read using the standard newline as
terminator.
This function may block waiting for input.
Check that all the arguments in ARGV
are file names of existent files. Return with code zero
if no errors, else print an error message and return with code 1.
This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.