On 3 Feb 2018, at 8:33, Martin Batholdy wrote:

Unfortunately, I have not found a fix for this behavior yet
If anyone has experienced similar problems and found a workaround – I would highly appreciate it!

How about writing the text to a temporary file and then execute the file in terminal?

You could do this with local echo enabled (set -x for bash) so you can see what is actually being executed.