4 ms·
Personally I use this pattern to make subcommands: main() { if [[ $1 ]]; then cmd_"$@" return fi cmd
by xdennis 4y ago
Personally I use this pattern to make subcommands:
main() {
if [[ $1 ]]; then
cmd_"$@"
return
fi
cmd_all "$@"
}
cmd_all() {
cmd_something "$@"
cmd_some-other-thing
}
cmd_something() {
...
}
cmd_some-other-thing() {
...
}
main "$@"
I find it much easier to understand when you execute things in a predictable order and you can have a `set -x` to follow everything through. If it's too slow, then only the show bits should be parallelized.
At work, on the other hand, every project uses something like this in the Makefile:
-include $(shell 'pwd')/makefile-modules/*/*Makefile*
That, and wildcard job names makes it quite difficult to follow the flow when things break.