wizard: write_env writes a corrupt .env when the value contains a newline (e.g. a PEM key or service-account JSON)
## Skill `wizard` (`skills/engineering/wizard/template.sh`, `write_env`) ## Version or commit a496f55 (also in the 4.x template) ## Harness and version n/a — reproduced by executing the template library directly, not in an agent session. ## Model and effort n/a — environment-mechanical, reproduces with the template alone. ## What happened `write_env KEY ` writes an unterminated `KEY='...` entry split across rows, so the `.env` is no longer parseable by `source` or any common dotenv reader, and `_existing` reads a corrupted value back. A multiline value is realistic for a wizard that stores a PEM private key or a service-account JSON. Repro (source the library above the `# STAGES` marker, bash 5.2): ```bash sed '/^# STAGES/,$d' template.sh > lib.sh && source ./lib.sh ENV_FILE=.env write_env TOKEN "$(printf 'line1\nline2')" cat -A .env ``` Produces a parse-broken file: ``` TOKEN='line1$ line2' ``` `_existing TOKEN` then returns `'line1` — the file has an unterminated single quote and the value is lost, silently. ## What you expected When the value contains a newline, `write_env` should fail loudly and leave `.env` unchanged (a single-value-per-line dotenv cannot hold such a value), rather than write an unterminated quoted line. ## Checks - [x] This issue is about one problem. - [x] I searched open and closed issues for a duplicate (none; `write_env` is in #770/#1345/#1260, which do not cover newlines).