Files
nixpkgs/pkgs/build-support/setup-hooks/arrayUtilities/isDeclaredMap/isDeclaredMap.bash

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
450 B
Bash
Raw Normal View History

2025-10-09 14:15:47 +02:00
# shellcheck shell=bash
# isDeclaredMap
# Tests if inputMapRef refers to a declared, associative array.
#
# Arguments:
# - inputMapRef: a reference to an associative array (not mutated)
#
# Returns 0 if the associative array is declared, 1 otherwise.
isDeclaredMap() {
# NOTE: We must dereference the name ref to get the type of the underlying variable.
# shellcheck disable=SC2034
local -nr inputMapRef="$1" && [[ ${!inputMapRef@a} =~ A ]]
}