Redjard posted on Fri, 18 Aug 2023 21:38:37 +0200 as excerpted:

> From: Redjard <eselect.patches.gen...@redjard.org>
> 
> Add Hooks to Eselect
> 
> For example for "eselect kernel list" the script
> /etc/eselect/hooks/kernel/list/pre is called before the eselect acts,
> and /etc/eselect/hooks/kernel/list/post afterwards.

Suggestion: A more flexible approach would make pre/post directories, such 
that "any" file therein (exceptions for backups, etc) would be sourced.

In run_hook something like (as written assumes bashisms OK, didn't verify 
if that's valid for eselect or not):

local action=$1
local subaction=$2
local hookscriptdir=$3

for $hookfile in
        /etc/eselect/hooks/${action}/${subaction}/${hookscriptdir}/*
do [[
                # maybe skip either the executable or README test?
                # or perhaps only match *.sh filenames instead
                # to reflect the in-shell sourcing?
                -x $hookfile &&
                $hookfile == ${hookfile#README} &&
                $hookfile == ${hookfile#.} &&
                $hookfile == ${hookfile%.bak} &&
                $hookfile == ${hookfile%\~}
        ]] && source "$hookfile"
done


-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman


Reply via email to