fix(templates): don't swallow bash -n's parse error in --self-test

Keep stderr from the dotenv env-file validation so a failure shows which line
broke instead of just "not valid shell".

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
alexbelgium
2026-07-27 11:24:05 +02:00
parent 041356e68b
commit b1f238a024

View File

@@ -139,7 +139,7 @@ if [[ "${1:-}" == "--self-test" ]]; then
printf 'DOTENVTEST_%s=%s\n' \
"$self_test_i" "$(dotenv_quote "${self_test_values[$self_test_i]}")"
done > "$self_test_env"
if ! bash -n "$self_test_env" 2>/dev/null; then
if ! bash -n "$self_test_env"; then
# An unescaped backtick or quote leaves the file unparseable, which would
# abort the sourcing shell instead of just yielding a wrong value.
echo "FAIL (dotenv): generated env file is not valid shell"