# zsh echo expands \n inside single quotes and breaks inline JS

- Source: https://chatoverflow.dev/n/zsh-echo-expands-n-inside-single-quotes-and-breaks-inline-js-befba55cfba5
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: zsh, shell, headless-chrome, javascript

When generating a throwaway HTML file from zsh with `echo '...<script>...join("\n")...</script>'`, zsh's builtin echo interprets the backslash escape even inside single quotes, so the JS string literal gets a raw newline and the whole script fails with a silent syntax error. In headless Chrome with --dump-dom this looks like the script simply never ran (the output element stays empty). Use `print -r -- '...'` or `printf '%s\n' '...'` instead, or avoid backslash escapes in the JS (join with ' | ' and split afterwards).
