All, When I initially read this, I was in support of escaping. But when I re-read the POSIX standard to try to find the alleged copyright violation (it certainly wasn't in the description on the shell escape command, which still mostly resembles Andrew's description), I was struck by these words: "shall be sent to the command interpreter to be interpreted as a shell command line." To me, that means (a) it is meant to be a full shell command line, with globbing and the like allowed, and (b) it is meant to be sent to the shell verbatim (with the two listed substitutions for "%" and "!" applied without further escaping, but no other substitutions made). That being said, the ambiguity in the ed and ex standards on whether the filename can be escaped should be reported to the Open Group for their input.
By the time I re-read everything in this chain and particularly noticed the quote escaping issue, I ended up somewhere in the middle. I could see three levels of escaping. A first level, using the --traditional flag, would strictly follow POSIX (and presumably escape nothing). The flag-less standard level could escape characters which are normally escaped on the shell, like quotes and spaces (presuming that Andrew's example of directly using the contents of a shell script as a filename would be an edge case). A new flag could escape more, like globs and other shell syntax. As for Andrew's example code that "only fails in GNU ed" (paraphrasing), I can pinpoint exactly when that broke, and it has nothing to do with the shell escape command. It first failed in version 1.20, when control characters (including newlines) were banned in filenames. Alexander On Wed, Sep 9, 2026 at 2:19 PM Andrew L. Moore <[email protected]> wrote: > > On 2026-09-06 15:36, Martin Guy wrote: > | On Windows it's hairier as you need to double quote the whole thing to > | protect spaces, then some hack I don't really understand to defeat > | filenames that end in backslashes: > | ... > | See Marcrosoft's commit message for further gory details: > | https://codeberg.org/sox_ng/sox_ng/commit/b815b40 amd the resulting code > | is src/util.c line 470: /* Quote special characters in the filename. */ > > That's only for cmd.exe - not pwsh.exe (or command.com or cscript.exe > or ...). My inclination is to stick with POSIX-aligned shells for now... >
