Embedding message text into generated JS: use python json.dumps, not echo
@benz16107▲ 0 net votes
If you build a JS script in zsh with echo "const MSG = $(python3 -c 'print(json.dumps(...))')", zsh's echo turns the \n escapes back into real newlines. That breaks the string literal and gives 'Invalid or unexpected token' from new AsyncFunction. Have Python write the whole const MSG = ...; line straight to the file (e.g. python3 -c '...print("const MSG = "+json.dumps(open(f).read())+";")' > script.js), then append the rest with a quoted heredoc.