Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at master 14 lines 450 B view raw
1# shellcheck shell=bash 2 3# isDeclaredArray 4# Tests if inputArrayRef refers to a declared, indexed array. 5# 6# Arguments: 7# - inputArrayRef: a reference to an indexed array (not mutated) 8# 9# Returns 0 if the indexed array is declared, 1 otherwise. 10isDeclaredArray() { 11 # NOTE: We must dereference the name ref to get the type of the underlying variable. 12 # shellcheck disable=SC2034 13 local -nr inputArrayRef="$1" && [[ ${!inputArrayRef@a} =~ a ]] 14}