Inside of a variable, a newline is encoded as
^@ which represents a null byte.
In the vim Ex command line it is possible to issue something like
substitute(var, '^@', '\\n', 'g'), this produces
\n instead which can be passed to e.g. bash cleanly.
However, putting this into a function inside my vimrc breaks horribly with a missing quote E115, so I have to escape it somehow, but I cannot figure out how.