From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9F35C15800A for ; Mon, 21 Aug 2023 00:15:20 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6F3942BC044; Mon, 21 Aug 2023 00:15:16 +0000 (UTC) Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 463C62BC016 for ; Mon, 21 Aug 2023 00:15:16 +0000 (UTC) Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1qXsZf-0004Jj-05 for gentoo-dev@lists.gentoo.org; Mon, 21 Aug 2023 02:15:15 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: gentoo-dev@lists.gentoo.org From: Duncan <1i5t5.duncan@cox.net> Subject: [gentoo-dev] Re: Add Hooks to Eselect Date: Mon, 21 Aug 2023 00:15:08 -0000 (UTC) Message-ID: References: <840371d1-21b3-f71b-03e0-0ef5b5ca2059@julianahl.de> <5ccfe79a-3a85-9b76-62af-34a75b7802ea@julianahl.de> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User-Agent: Pan/0.154 (Izium; b9ffd3c66) X-Archives-Salt: 01d17376-bde5-4111-b860-1bf6f718a9f5 X-Archives-Hash: 4ca8e3ce3e2fa0e37dedd7b70e0b016b Redjard posted on Fri, 18 Aug 2023 21:38:37 +0200 as excerpted: > From: Redjard > > 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