2019-06-21 09:05:09 +0100, Stephane Chazelas: [...] > That autoconf example above is actually pretty damning. [...] > as_echo='printf %s\n' [...]
Another ironic thing with that example is that that autoconf code is about working around the fact that the POSIX echo is not usable. In http://austingroupbugs.net/bug_view_page.php?bug_id=1222 I asked that POSIX *allows*, not even mandate an interface supported by one sh implementation and documented as such for over 25 years (since before the first version of the POSIX.2 specification) that addresses that: echo -E - "$var" That's not such a useless feature. Without it, echo can't be used to output arbitrary data, which is exactly what that autoconf as_echo is trying to do. It was rejected (even the "just allowing it") on the ground that it would break existing scripts (without providing any evidence; no need to look now, I know it does break some). That would break scripts that pass "-" as the *first* argument of *one* command (echo) and that happen to be interpreted by a shell that has implemented that allowed, but not required feature. My point was so that POSIX warn people against expecting "echo -" to output "-" as it does not in all shells in practice. Instead, now, POSIX want to *mandate* not only allow a feature that not a single shell has done, that is not needed at all, and that would potentially break all scripts that pass an unquoted word expansion containing a backslash in *any* position, in *any* argument to *any* command. Isn't there some level of double standard there? -- Stephane