Skip to content

Commit ef06a29

Browse files
committed
test 4
1 parent af83232 commit ef06a29

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scripts/dev/switch_context.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ else
6767
fi
6868
# Execute the command in a clean environment and capture exported variables
6969
# Let's use our PATH as a base to have utilities available.
70-
current_envs=$(env -i PATH="${PATH}" CURRENT_VARIANT_CONTEXT="${context}" bash -c "${base_command} && export -p")
70+
current_envs=$(env -i PWD="${PWD}" PATH="${PATH}" CURRENT_VARIANT_CONTEXT="${context}" bash -c "${base_command} && export -p")
7171

7272
# `export -p` instead of `env` ensures we can safely re-source variables which we rely on further
7373
# below like our operator.print.env script
@@ -76,7 +76,8 @@ else
7676
fi
7777

7878
# convert declare -x key=value into key=value
79-
current_envs=$(echo "${current_envs[@]}" | sed 's/^declare -x //g' | sed 's/=/=/'| sort | uniq)
79+
# filter out variables that don't have value (missing '=')
80+
current_envs=$(echo "${current_envs[@]}" | grep '=' | sed 's/^declare -x //g' | sed 's/=/=/'| sort | uniq)
8081

8182
echo -e "## This file is automatically generated by switch_context.sh\n## Do not edit it!" > "${destination_envs_file}.env"
8283
# shellcheck disable=SC2129

0 commit comments

Comments
 (0)