Artyom Bologov wrote:
In any way, a proper escaping mechanism is really needed here,

Then why POSIX does not require it?

I have no idea. The phrasing in the manpage is not the clearest:

     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

POSIX says the same[1], and I think it is pretty clear: '%' shall be replaced with the remembered pathname, not with a modified version of the remembered pathname. Ed is not supposed to modify the remembered pathname so that it can be later fed to the shell.

[1] http://pubs.opengroup.org/onlinepubs/9799919799/utilities/ed.html

I guess the only portable thing you can do is to only search for words that are valid file names.

Antonio.

Reply via email to