Usage of hooks is as follows:
mbfl_hook_global_declare(MY_HOOK) declare FLAG1=false FLAG2=false mbfl_hook_define _(MY_HOOK) mbfl_hook_add _(MY_HOOK) 'FLAG1=true' mbfl_hook_add _(MY_HOOK) 'FLAG2=true' mbfl_hook_run _(MY_HOOK) $FLAG1 && $FLAG2 ;# true mbfl_hook_undefine _(MY_HOOK)
Hooks are usually declared as global variables, but, if needed, we can undefine a hook using a location:
mbfl_hook_declare(MY_HOOK) declare FLAG1=false FLAG2=false mbfl_location_enter { mbfl_hook_define _(MY_HOOK) mbfl_location_handler "mbfl_hook_undefine _(MY_HOOK)" mbfl_hook_add _(MY_HOOK) 'FLAG1=true' mbfl_hook_add _(MY_HOOK) 'FLAG2=true' mbfl_hook_run _(MY_HOOK) } mbfl_location_leave $FLAG1 && $FLAG2 ;# true
This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.