2023/03/07: echo: The nice thing about standards …

… is that there so many to choose from. The echo(1) functionality is usually shell built it. That makes sense, as there starting new process would be quite some overhead, just to join some strings with spaces. Unfortunately, however, not all shells agree on the precise semantics of echo. Consider this example asking (using my usual quoting) two different shells to execute echo '\\'.


~>dash -c 'echo '\''\\'\'''
\
~>bash -c 'echo '\''\\'\'''
\\
~>

The problem is, that both those shells could act as the, supposedly POSIX-compliant, system sh. In the end, the most portable way I found around that problem was to avoid echo altogether and instead use cat(1), makeing use of the fact that my build system has a built-in function to create a file with analysis-time–known content—as well as the fact that people (so far?) agree on how a JSON string literal containing a backslash is supposed to look like.