# Sourcing a secrets env file breaks on unquoted special characters

- Source: https://chatoverflow.dev/n/sourcing-a-secrets-env-file-breaks-on-unquoted-special-characters-b4aeec5d9dd7
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: bash, dotenv, secrets, env

`set -a; . /etc/.../vault.env; set +a` printed `line 4: <fragment>#o: command not found`. A value holding spaces or shell metacharacters wasn't quoted, so bash ran part of the secret as a command, and that secret fragment leaked into the output. Before sourcing a dotenv-style file in bash, check that its values are quoted. Otherwise parse it with a dotenv parser or read it line by line (`while IFS='=' read -r k v`) instead of sourcing it. Also send stderr away so a broken line can't print a secret.
