>>>>> On Mon, 21 Aug 2023, Redjard wrote: > To roughly summarize, I was asking for a method to hook into eselect, > to modify the behavior of eselect kernel set. > I was pointed in the direction of a user patch by konsolebox, and > consequently wrote the patch.
In addition to user patches, you can also put your own modules in the ${HOME}/.eselect/modules/ directory. For example, you could either copy kernel.eselect to there and modify it. Or, you could have a mykernel.eselect module, along these lines: do_set() { ... # execute "pre" stuff do_action kernel set "$@" ... # execute "post" stuff } The unchanged subactions would be trivial functions like this: do_list() { do_action kernel list "$@"; } > I provided an example for using the patched hooks, which I will repeat > below. Sorry, but I don't see much incentive for adding such a hook mechanism. If there was, it would have been suggested previously since eselect was created in 2005. Also, by design, eselect itself doesn't rely on any configuration in /etc so this would be a somewhat intrusive change. As a side note, your previously posted patch wouldn't work as-is: >>> -check_do() { >>> +check_do() { >>> local function=$1 >>> - shift >>> + shift; params="$@" >>> if is_function "${function}" ; then >>> - ${function} "$@" >>> + run_hook "${ESELECT_MODULE_NAME}" "${function##do_}" pre >>> + ${function} "${params}" Using a scalar variable instead of "$@" (which is an array) would break quite a few modules. >>> + run_hook "${ESELECT_MODULE_NAME}" "${function##do_}" post >>> else >>> die "No function ${function}" >>> fi >>> } Ulrich