wryun / es-shell

es: a shell with higher-order functions
http://wryun.github.io/es-shell/
Other
313 stars 26 forks source link

Support $"var and "{} and turn echo Posix compatible #22

Closed eadwardus closed 5 years ago

eadwardus commented 5 years ago

The original rc supported $"var (in es being $^var the equivalent), and inferno sh supports the "{} (that is the equivalent to { a=`{ls}; a=$^a }), both are convenient to be natively supported (while i think that $"var and "{} are more natural, alternatively ^{} could be supported). Note that this isn't a new construct and just runs upon %backquote, and that "command doesn't work, different from `command

Posix describes that echo should interpret '--' as a simple string operand.

wryun commented 5 years ago

Hi @eadwardus , as much as I'm thrilled to receive a PR for es, I'm concerned that this will change the behaviour of existing scripts (more so with the ` ~= " than the echo change, though both are issues). I mostly think of es as being in maintenance mode, so backwards incompatible changes would need compelling reasons.

Other thoughts - I don't really think POSIX echo compatibility is critical for a builtin in a definitely non-POSIX shell, and I'm not sure rc/inferno compatibility is really that interesting either (" was presumably intentionally changed by the original es authors).

If you're keen on improving es, you might want to contribute https://github.com/TieDyedDevil/XS. Or you're most welcome to maintain your own fork! Or you can try to change my mind - I'll leave this open for now in case I have a change of heart.

eadwardus commented 5 years ago

I understand, breaking backward compatibility only because of this "feature" seems too much, and implementing this with ^{ seems bad too, as it is used to concatenate lists

The thing for echo is that POSIX declare it under its utilities[0], and is an external utility (does not need to be implemented inside the shell, instead of cd for example), that said, this is more purism, this behaviour would hardly break anything. In this case, it's less about mimiking the rc/inferno and more about extending the " or ^ behaviour, as in this point compatibility would result in a giant mess

0:http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html