File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ if [ -f "$CALL_HOST_CONFIG" ]; then
88 source " $CALL_HOST_CONFIG "
99fi
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
1217is_zsh (){
1318 # detect the current shell process name (portable ps usage)
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
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
7584fi
7685
77- # portable indirect variable access (works in both bash and zsh)
78- getvar (){
79- eval " printf '%s' \"\$ {$1 :-}\" "
80- }
81-
8286# validation
8387call_host_valid (){
8488 VAR_TO_VALIDATE=" $1 "
You can’t perform that action at this time.
0 commit comments