fix: preserve local env overrides in shell pipelines
This commit is contained in:
21
scripts/load_project_env.sh
Executable file
21
scripts/load_project_env.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
PATH_ARG="${1:-}"
|
||||
[[ -n "$PATH_ARG" && -f "$PATH_ARG" ]] || exit 0
|
||||
|
||||
python3 - <<'PY' "$PATH_ARG"
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
for raw in Path(sys.argv[1]).read_text().splitlines():
|
||||
s = raw.strip()
|
||||
if not s or s.startswith('#') or '=' not in s:
|
||||
continue
|
||||
key, value = s.split('=', 1)
|
||||
key = key.strip()
|
||||
value = value.strip().strip('"').strip("'")
|
||||
if not key or not value:
|
||||
continue
|
||||
print(f"{key}={value}")
|
||||
PY
|
||||
Reference in New Issue
Block a user