marcus-g
5/5/2017 - 8:54 PM

Forward declaration in shell scripts are most elegantly handled by including a main function up-top that handles the execution order of the

Forward declaration in shell scripts are most elegantly handled by including a main function up-top that handles the execution order of the script. Then anywhere else in the script, preferably last, simply call: main "$@"

From http://stackoverflow.com/questions/13588457/forward-declarations-in-bash/13588485

#!/bin/bash

main() {
    foo
    bar
    baz
}

foo() {
}

bar() {
}

baz() {
}

main "$@"