Hello,
Using GNU bash 5.0.17(1) and GNU ed version 1.16 the command
printf '%s\n' 'r !date +"% modified on \%F"' ',p' Q | ed -s fil1
outputs
date +"fil1 modified on \%F"
fil1 modified on \2021-07-10
I think the output should contain no backslashes, per POSIX
documentation. The GNU ed manual would benefit from clarification.
POSIX
<https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ed.html>
says following about the Shell Escape Command:
"The remainder of the line after the '!' shall be sent to the command
interpreter to be interpreted as a shell command line. Within the text
of that shell command line, the unescaped character '%' shall be
replaced with the remembered pathname"
GNU ed manual - section `Commands, !COMMAND` - says:
"'ed' does not process COMMAND for backslash ('\') escapes. However,
an unescaped '%' is replaced by the default filename."
Regards,
M. Thomsen
DK-8000 Aarhus