From 2513bef471ae681ec81cf4b056952095c0011a23 Mon Sep 17 00:00:00 2001 From: Josh Bode Date: Tue, 26 Mar 2024 08:26:02 +1100 Subject: [PATCH] Allow filtering list of exported variable names --- bin/utils.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/utils.sh b/bin/utils.sh index 1d42a38..dd82f6d 100755 --- a/bin/utils.sh +++ b/bin/utils.sh @@ -9,7 +9,7 @@ echoerr() { } sops_bin() { - echo "$MISE_INSTALL_PATH/bin/sops" + echo "${MISE_INSTALL_PATH}/bin/sops" } sops_env() { @@ -18,6 +18,13 @@ sops_env() { return 1 fi + # export names filter + if [[ -n ${MISE_TOOL_OPTS__NAMES-} ]]; then + NAMES="\(${MISE_TOOL_OPTS__NAMES//:/\\|}\)" + else + NAMES="\w\+" + fi + while read -r filename; do if [[ ${filename} != /* ]] && [[ -n ${MISE_PROJECT_ROOT-} ]]; then filename="${MISE_PROJECT_ROOT-}/${filename}" @@ -27,5 +34,5 @@ sops_env() { continue fi "$(sops_bin)" -d "${filename}" - done < <(tr : $'\n' <<<"${MISE_TOOL_OPTS__FILENAME}") + done < <(tr : $'\n' <<<"${MISE_TOOL_OPTS__FILENAME}") | grep "^export ${NAMES}=" }