Skip to content

Commit

Permalink
BUGFIX: set_or_default was not taking defaults into account
Browse files Browse the repository at this point in the history
  • Loading branch information
drivera-armedia committed Aug 27, 2024
1 parent 8fbd5a8 commit 5658d73
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,9 @@ to_array()

__var_set_tool()
{
[ ${#} -ge 1 ] || return 1
[ ${#} -ge 2 ] || return 1
local __FUNC="${1}"
shift

local __VAR="${1}"

Expand Down Expand Up @@ -748,7 +750,7 @@ __var_set_tool()

# If we've been given a function to process the result
# before we return it, we use it
[ ${#} -ge 3 ] && __RESULT="$("${3}" "${__RESULT}")"
[ -n "${__FUNC}" ] && __RESULT="$("${__FUNC}" "${__RESULT}")"

# Declare it, keeping its export status!
declare -g${__X} ${__VAR}="${__RESULT}"
Expand All @@ -769,7 +771,7 @@ __var_set_tool()
#
set_or_default()
{
__var_set_tool "${1}" "${2:-}"
__var_set_tool "" "${@}"
}

#
Expand All @@ -780,7 +782,7 @@ set_or_default()
#
set_as_boolean()
{
__var_set_tool "${1}" "${2:-false}" to_boolean
__var_set_tool to_boolean "${@}"
}

#
Expand Down

0 comments on commit 5658d73

Please sign in to comment.