# shellcheck shell=sh
# Resolve one catalogue key and print it (AD-34). The seed that invokes a
# hook may carry a KEY but never a sentence: a seed is never overwritten,
# so a sentence there would be frozen for every existing install, while
# this script and the catalogue are owned artifacts replaced every time.
#
# Prints nothing when the key or the catalogue is missing. For a
# UserPromptSubmit hook that means no injected context rather than a
# wrong or stale instruction -- silence is the safe failure here.

set -u
[ "$#" -ge 1 ] || exit 0
catalogue_="$(dirname "$0")/messages.txt"
[ -r "${catalogue_}" ] || exit 0
LC_ALL=C awk -F'\t' -v k="$1" '$1==k {printf "%s", $2; exit}' "${catalogue_}" 2>/dev/null
exit 0
