From 50c1e5af53a2ade8692bcfd1a62f6db0ae3ca09d Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Thu, 22 Dec 2022 15:57:48 +0900 Subject: [PATCH] toolbox.sh: Don't require interfaces to be included manually When a module implements an interface, it has to include the module that defines the interface before calling `implements()'. However, since the name of an interface and the module that defines it are necessarily identical, there is no ambiguity and the module should be included automatically. This commit modifies the function `implements()' so that it includes the interface's module before registering the implementation. --- toolbox.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/toolbox.sh b/toolbox.sh index 802c5cc..71e5725 100644 --- a/toolbox.sh +++ b/toolbox.sh @@ -234,6 +234,10 @@ implements() { local method declare -n interface + if ! include "$iface"; then + return 1 + fi + if [[ -z "${__TOOLBOX_INTERFACES[$iface]}" ]]; then echo "ERROR: Unknown interface: \"$iface\"" 1>&2 return 1 -- 2.47.3