[arch-projects] [devtools] makechrootpkg: Keep everything inside of a function
lukeshu at lukeshu.com
lukeshu at lukeshu.com
Wed Apr 5 22:39:34 UTC 2017
I think that this is the last change from Parabola that would be
welcome in devtools.
It shoves the initial variable setup inside of a `init_variables()`
function, and the loose code at the end into a `main()` function,
which it calls as the very last line.
My motivation for this is that in Parabola, makechrootpkg is used as a
library, not as an executable, and so this makes adjusting it to be a
library as simple as removing the `main "$@"` line from the end.
However, I do think that the change stands on its own for 2 reasons;
using a `main()` function is good because
- deferring execution until the entire script has been parsed avoids
weird things happening if the user upgrades the program while an
instance of it is running
- generally good for code quality
Naturally, this re-indents a a decent size block of code, which means
that rebasing or merging with it is a pain.
--
Happy hacking,
~ Luke Shumaker
More information about the arch-projects
mailing list