Skip to content

Commit 544e217

Browse files
wenausclaude
andcommitted
Fix env loading to skip unexpanded shell variables
Skip entries containing $ in setup_environment() to prevent PATH being overwritten with literal "$PATH" string from ~/.env 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6f8bba3 commit 544e217

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/swf_common_lib/base_agent.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ def setup_environment():
5353
if line.startswith('export '):
5454
line = line[7:] # Remove 'export '
5555
key, value = line.split('=', 1)
56-
os.environ[key] = value.strip('"\'')
57-
56+
value = value.strip('"\'')
57+
# Skip entries with unexpanded shell variables (e.g., PATH=$PATH:...)
58+
# These are already expanded by shell when it sourced ~/.env
59+
if '$' in value:
60+
continue
61+
os.environ[key] = value
62+
5863
# Unset proxy variables to prevent localhost routing through proxy
5964
for proxy_var in ['http_proxy', 'https_proxy', 'HTTP_PROXY', 'HTTPS_PROXY']:
6065
if proxy_var in os.environ:

0 commit comments

Comments
 (0)