Skip to content

Commit 4720062

Browse files
CodeGhost21claude
andcommitted
Fix load-dotenv.sh crash on empty .env file
Handle empty exports array to avoid 'unbound variable' error when .env exists but contains no key-value pairs (e.g. CI touch-created). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent df5fd85 commit 4720062

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

scripts/load-dotenv.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ while IFS= read -r line || [[ -n "$line" ]]; do
3838
fi
3939
done < "$RESOLVED"
4040

41-
joined=$(printf '%s\n' "${exports[@]}")
41+
if [[ ${#exports[@]} -eq 0 ]]; then
42+
joined=""
43+
else
44+
joined=$(printf '%s\n' "${exports[@]}")
45+
fi
4246

4347
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
4448
echo "$joined"

0 commit comments

Comments
 (0)