summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGianni Ceccarelli <gianni.ceccarelli@broadbean.com>2023-07-14 12:21:21 +0100
committerGianni Ceccarelli <gianni.ceccarelli@broadbean.com>2023-07-14 12:21:21 +0100
commitcc99c87c988b5f91fdd433b11beeaec91318d4cc (patch)
treea4e63b3b5d4d8d724179028225eec19d57be92a3
parentmethod dispatch seems to work (diff)
downloadbash-object-system-cc99c87c988b5f91fdd433b11beeaec91318d4cc.tar.gz
bash-object-system-cc99c87c988b5f91fdd433b11beeaec91318d4cc.tar.bz2
bash-object-system-cc99c87c988b5f91fdd433b11beeaec91318d4cc.zip
fix find-method-into
`${#foo}` is the character length of the first element of `foo` (because `$foo` is that first element), `${#foo[@]}` is the number of elements
-rw-r--r--bos-mop.sh4
1 files changed, 2 insertions, 2 deletions
diff --git a/bos-mop.sh b/bos-mop.sh
index e18baec..7cd28c7 100644
--- a/bos-mop.sh
+++ b/bos-mop.sh
@@ -27,7 +27,7 @@ function bos/mop/base/find-method-into() {
# if we don't have a $start_from_class, it means we're doing the
# initial method resolution, so don't skip any class in $mro
if [[ -n "$start_from_class" ]]; then
- for (( ; idx <= "${#mro}" ; ++idx )); do
+ for (( ; idx < "${#mro[@]}" ; ++idx )); do
if [[ "${mro[$idx]}" == "$start_from_class" ]]; then
(( ++idx ))
break
@@ -35,7 +35,7 @@ function bos/mop/base/find-method-into() {
done
fi
- for (( ; idx <= "${#mro}" ; ++idx )); do
+ for (( ; idx < "${#mro[@]}" ; ++idx )); do
local full_name="${mro[$idx]}/${method}"
if declare -F "$full_name" >/dev/null; then
result="${full_name}"