summaryrefslogtreecommitdiff
path: root/scripts/sandbox_command.sh
diff options
context:
space:
mode:
authorOlcan <[email protected]>2025-06-02 14:16:48 -0700
committerGitHub <[email protected]>2025-06-02 14:16:48 -0700
commit8365c8f954b2732be3ec9441f8464117d4c0cb93 (patch)
tree7a29ed4ef13b2cef8ff2b80b56d5e886ed064bb7 /scripts/sandbox_command.sh
parent7f20425c98d5adb5531e6c33ed92975b71b34c90 (diff)
prefer to load gemini-specific .env file from .gemini folder when it exists there (#697)
Diffstat (limited to 'scripts/sandbox_command.sh')
-rwxr-xr-xscripts/sandbox_command.sh20
1 files changed, 15 insertions, 5 deletions
diff --git a/scripts/sandbox_command.sh b/scripts/sandbox_command.sh
index 7c140c61..325722f5 100755
--- a/scripts/sandbox_command.sh
+++ b/scripts/sandbox_command.sh
@@ -43,21 +43,31 @@ fi
# if GEMINI_SANDBOX is not set, try to source .env in case set there
# allow .env to be in any ancestor directory (same as findEnvFile in config.ts)
+# prefer gemini-specific .env under .gemini folder (also same as in findEnvFile)
if [ -z "${GEMINI_SANDBOX:-}" ]; then
current_dir=$(pwd)
dot_env_sourced=false
while [ "$current_dir" != "/" ]; do
- if [ -f "$current_dir/.env" ]; then
+ if [ -f "$current_dir/.gemini/.env" ]; then
+ source "$current_dir/.gemini/.env"
+ dot_env_sourced=true
+ break
+ elif [ -f "$current_dir/.env" ]; then
source "$current_dir/.env"
dot_env_sourced=true
break
fi
current_dir=$(dirname "$current_dir")
done
- # if .env is not found in any ancestor directory, try ~/.env as fallback
- if [ "$dot_env_sourced" = false ] && [ -f "$HOME/.env" ]; then
- source "$HOME/.env"
- dot_env_sourced=true
+ # if .env is not found in any ancestor directory, try home as fallback
+ if [ "$dot_env_sourced" = false ]; then
+ if [ -f "$HOME/.gemini/.env" ]; then
+ source "$HOME/.gemini/.env"
+ dot_env_sourced=true
+ elif [ -f "$HOME/.env" ]; then
+ source "$HOME/.env"
+ dot_env_sourced=true
+ fi
fi
fi