R286 Pass text through a shell with a quoted heredoc, on standard input or in a file
Pass a text to a command through a shell, when it runs over more than one line or holds $, a backtick, a backslash, a quote or !, with a quoted heredoc, fed to the command’s standard input or written into a file that the command reads.
Reason
Inside double quotes the shell expands $ and backticks: a value in the text is replaced by whatever the shell finds and a code span in Markdown runs as a command, with no error, so the text arrives changed and still reads well, and a number in it may state a fact that was never looked up (Art. VII §1(2)). When the text is quoted from someone else, a $(…) in it runs on the agent’s own machine, a command injection others can exploit (Art. II §7). In the same double quotes, a " in the text ends the string early, and a backslash before $, a backtick, " or another backslash is dropped. Single quotes break on the first apostrophe, and ! can set off history expansion. A heredoc with a quoted delimiter passes every character as written; fed to standard input it takes one step and leaves no file behind. Inside double quotes, a short text on one line with none of these characters passes unchanged, so it may stay on the command line.
Verification
The text covered is what a command takes as content, such as a message or a prompt for an agent, a request body, the body of a pull request, issue or comment, or a commit message; flags, paths and identifiers are not. A quoted heredoc is one whose delimiter is quoted, as in <<'EOF'. Feeding it to standard input means the command reads the text from there, for example with --body-file - or -F -; a command that reads no text from standard input gets a file written with a quoted heredoc instead.
Violated when an agent passes such a text to a command written into the command line, in any quoting, or writes it with a heredoc whose delimiter is not quoted.