Skip to content

Commit 9d1c5eb

Browse files
committed
some missing function exports for bash
1 parent 38a9e06 commit 9d1c5eb

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

call_host.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ if [ -f "$CALL_HOST_CONFIG" ]; then
88
source "$CALL_HOST_CONFIG"
99
fi
1010

11+
# portable indirect variable access (works in both bash and zsh)
12+
getvar(){
13+
eval "printf '%s' \"\${$1:-}\""
14+
}
15+
1116
# zsh / bash compatibility helpers
1217
is_zsh(){
1318
# detect the current shell process name (portable ps usage)
@@ -56,10 +61,12 @@ else
5661
# shellcheck disable=SC2163
5762
export -f "$1" 2>/dev/null || true
5863
}
64+
export_func getvar
5965
declare_assoc(){
6066
# create named associative array in bash
6167
declare -gA "$1"
6268
}
69+
export_func declare_assoc
6370
current_funcname(){
6471
# return the caller function name if available (FUNCNAME[1]), otherwise fall back to FUNCNAME[0]
6572
if [ -n "${FUNCNAME[1]:-}" ]; then
@@ -68,17 +75,14 @@ else
6875
echo "${FUNCNAME[0]:-}"
6976
fi
7077
}
78+
export_func current_funcname
7179
# get function definition (bash)
7280
get_function(){
7381
declare -f "$1" 2>/dev/null
7482
}
83+
export_func get_function
7584
fi
7685

77-
# portable indirect variable access (works in both bash and zsh)
78-
getvar(){
79-
eval "printf '%s' \"\${$1:-}\""
80-
}
81-
8286
# validation
8387
call_host_valid(){
8488
VAR_TO_VALIDATE="$1"

0 commit comments

Comments
 (0)