You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
syntax: a quoted heredoc processes backslash escapes #1390
A heredoc with a quoted delimiter must be literal — POSIX: "if the delimiter is quoted, the here-document lines shall not be expanded". Backslash escapes are processed anyway.
That is exactly the escape set an unquoted heredoc processes (\, \$, \`), so the quoted form appears to be taking the unquoted path for backslashes only. Everything else about quoting is correct: $HOME, $(cmd), `cmd` and $((1+1)) all stay literal under <<'X' and all expand under <<X, matching bash.
The consequence is that cat > file <<'EOF' — the idiom whose whole point is that the content is not interpreted — writes something other than what it was given, with no error and exit 0. It bites anything with a doubled backslash or an escaped $: shell and awk scripts, regexes whose source spelling is \d (JS, Java, JSON), Windows paths, LaTeX, printf formats, Makefile recipes.
Found by a bash-vs-gosh differential sweep (128 snippets, each run direct and through eval) while integrating interp as the substrate of a shell. Reproduced on gosh@v3.13.2-0.20260813221317-a04df9f0d4b8 against bash 5.3.15 on darwin/arm64. Happy to send a PR if the direction looks right.
Activity
interp: don't expand quoted here-documents