#!/bin/bash . "$(sfpath)" shellfu import pretty # # These functions look like from modules # # Normally these functions would have to be defined in separate # files and imported using `shellfu import `, but for the sake # of testing it's OK to pretend a bit. # # Note that they also follow the notation of demarking internal # functions by single or double underscore. # # # Look like from foomod # foomod__room() { debug "in a room" foomod__desk } foomod__desk() { debug "in a desk" foomod__drawer } foomod__drawer() { debug "in a drawer" _foomod__box } _foomod__box() { debug "in a secret box" __foomod__document } __foomod__document() { debug "in a secret document" barmod__page } # # Look like from barmod # barmod__page() { debug "on a page" barmod__paragraph } barmod__paragraph() { debug "in a paragraph" barmod__sentence } barmod__sentence() { debug "in a sentence" _barmod__word } _barmod__word() { debug "in an unknown word" __barmod__letter } __barmod__letter() { debug "is an unknown letter" } # # Look like defined here # # No particular convention is required for scripts; these functions # should "look local". # # Note that debug from main() will appear as if directly from the script # main body, not the function. As bash reports FUNCNAME as `main` for # code that is not in any function, this cannot be changed. # __really_do_process_task() { debug "totally really starting the task" foomod__room } __do_process_task() { debug "really starting the task" __really_do_process_task } process_task() { debug "about to do a task" __do_process_task } process_job() { debug "in house" process_task } main() { debug "just poking about" process_job } main "$@"