More Bash 4.x compatibility issues found and fixed

This commit is contained in:
Tyler Akins
2023-05-12 08:17:57 -05:00
parent 6cc72acde0
commit 68306c4c6d
4 changed files with 34 additions and 18 deletions

View File

@@ -3,7 +3,8 @@ cd "${0%/*}" || exit 1
. ../run-tests
declare -A repo
repo[resque]="Resque"
# The order of the array elements can be shuffled depending on the version of
# Bash. Keeping this to a minimal set and alphabetized seems to help.
repo[hub]="Hub"
repo[rip]="Rip"
export repo
@@ -18,7 +19,6 @@ expected() {
cat <<EOF
<b>hub - Hub</b>
<b>rip - Rip</b>
<b>resque - Resque</b>
EOF
}

View File

@@ -6,7 +6,21 @@ testArgs() {
local args
# shellcheck disable=SC2031
args=$(declare -p MO_FUNCTION_ARGS)
echo -n "${args#*=}"
# The output from declare -p could look like these
# declare -a MO_FUNCTION_ARGS=([0]="one")
# declare -ax MO_FUNCTION_ARGS='([0]="one")'
# Trim leading declare statement and variable name
args="${args#*=}"
# If there are any quotes, remove them. The function arguments will always
# be an array.
if [[ "${args:0:1}" == "'" ]]; then
args=${args#\'}
args=${args%\'}
fi
echo -n "$args"
}
template() {
cat <<EOF

View File

@@ -93,7 +93,7 @@ This is open source! Please feel free to contribute.
https://github.com/tests-always-included/mo
MO_VERSION=3.0.1
MO_VERSION=3.0.2
EOF
}