mirror of
https://github.com/tests-always-included/mo.git
synced 2026-04-08 00:40:38 +02:00
Finally accessed a Mac to replicate the issue
This commit is contained in:
22
mo
22
mo
@@ -904,25 +904,39 @@ mo::parseValue() {
|
|||||||
mo::isFunction() {
|
mo::isFunction() {
|
||||||
local moFunctionName
|
local moFunctionName
|
||||||
|
|
||||||
|
# Need to test for the array length, otherwise Mac will report an
|
||||||
|
# unbound variable
|
||||||
|
if [[ "${#MO_FUNCTION_CACHE_HIT[@]}" -gt 0 ]]; then
|
||||||
for moFunctionName in "${MO_FUNCTION_CACHE_HIT[@]}"; do
|
for moFunctionName in "${MO_FUNCTION_CACHE_HIT[@]}"; do
|
||||||
if [[ "$moFunctionName" == "$1" ]]; then
|
if [[ "$moFunctionName" == "$1" ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${#MO_FUNCTION_CACHE_MISS[@]}" -gt 0 ]]; then
|
||||||
for moFunctionName in "${MO_FUNCTION_CACHE_MISS[@]}"; do
|
for moFunctionName in "${MO_FUNCTION_CACHE_MISS[@]}"; do
|
||||||
if [[ "$moFunctionName" == "$1" ]]; then
|
if [[ "$moFunctionName" == "$1" ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
if declare -F "$1" &> /dev/null; then
|
if declare -F "$1" &> /dev/null; then
|
||||||
|
if [[ "${#MO_FUNCTION_CACHE_HIT[@]}" -gt 0 ]]; then
|
||||||
MO_FUNCTION_CACHE_HIT=( ${MO_FUNCTION_CACHE_HIT[@]+"${MO_FUNCTION_CACHE_HIT[@]}"} "$1" )
|
MO_FUNCTION_CACHE_HIT=( ${MO_FUNCTION_CACHE_HIT[@]+"${MO_FUNCTION_CACHE_HIT[@]}"} "$1" )
|
||||||
|
else
|
||||||
|
MO_FUNCTION_CACHE_HIT=( "$1" )
|
||||||
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "${#MO_FUNCTION_CACHE_MISS[@]}" -gt 0 ]]; then
|
||||||
MO_FUNCTION_CACHE_MISS=( ${MO_FUNCTION_CACHE_MISS[@]+"${MO_FUNCTION_CACHE_MISS[@]}"} "$1" )
|
MO_FUNCTION_CACHE_MISS=( ${MO_FUNCTION_CACHE_MISS[@]+"${MO_FUNCTION_CACHE_MISS[@]}"} "$1" )
|
||||||
|
else
|
||||||
|
MO_FUNCTION_CACHE_MISS=( "$1" )
|
||||||
|
fi
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -1017,8 +1031,8 @@ mo::isArrayIndexValid() {
|
|||||||
# declare -p z # Error code 1 and output: bash: declare: z: not found
|
# declare -p z # Error code 1 and output: bash: declare: z: not found
|
||||||
#
|
#
|
||||||
# Returns true (0) if the variable is set, 1 if the variable is unset.
|
# Returns true (0) if the variable is set, 1 if the variable is unset.
|
||||||
unset MO_VAR_TEST_FOR_DECLARE
|
MO_VAR_TEST="ok"
|
||||||
if declare -p "MO_VAR_TEST_FOR_DECLARE" &> /dev/null; then
|
if test -v "MO_VAR_TEST" &> /dev/null; then
|
||||||
mo::debug "Using declare -p and [[ -v ]] for variable checks"
|
mo::debug "Using declare -p and [[ -v ]] for variable checks"
|
||||||
# More recent Bash
|
# More recent Bash
|
||||||
mo::isVarSet() {
|
mo::isVarSet() {
|
||||||
@@ -1041,6 +1055,7 @@ else
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
unset MO_VAR_TEST
|
||||||
|
|
||||||
|
|
||||||
# Internal: Determine if a value is considered truthy.
|
# Internal: Determine if a value is considered truthy.
|
||||||
@@ -1458,7 +1473,8 @@ mo::standaloneProcess() {
|
|||||||
mo::escape moTemp "$MO_PARSED"
|
mo::escape moTemp "$MO_PARSED"
|
||||||
mo::debug "$moTemp"
|
mo::debug "$moTemp"
|
||||||
|
|
||||||
while [[ "${MO_PARSED:$moI:1}" == " " || "${MO_PARSED:$moI:1}" == $'\t' ]]; do
|
# Mac appears to allow getting characters from before the start of the string
|
||||||
|
while [[ "$moI" -ge 0 ]] && [[ "${MO_PARSED:$moI:1}" == " " || "${MO_PARSED:$moI:1}" == $'\t' ]]; do
|
||||||
moI=$((moI - 1))
|
moI=$((moI - 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user