Skip to content

Commit

Permalink
Allow filtering list of exported variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbode committed Mar 25, 2024
1 parent e70f9da commit 2513bef
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bin/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ echoerr() {
}

sops_bin() {
echo "$MISE_INSTALL_PATH/bin/sops"
echo "${MISE_INSTALL_PATH}/bin/sops"
}

sops_env() {
Expand All @@ -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}"
Expand All @@ -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}="
}

0 comments on commit 2513bef

Please sign in to comment.