I’m trying to work with the raw output from a Julia process but I don’t understand even a simple version of it.
I tried julia --banner=no | tee julia.txt, then typed 1+2 and enter. The file julia.txt then looks like this (I replaced escape characters with \e here:
I don’t get how the ANSI escape codes lead to that result. \e[0K means “delete from cursor to end of line” and \e[7C means "move cursor forward 7 steps. The output has julia> two times, but in the raw output it’s 4 times. However, the cursor only ever moves forward, and only ever deletes to the end of the line. How does it work out to the final result then?
One more peculiarity, when I do cat julia.txt I get the correct output. However, when I do echo 'paste the content of the file here' I get:
julia>
1+2
julia>
1+2
3
julia>
julia>
And this is the output I would expect if I trace the ansi escape code commands in there. Where’s the problem in my logic?
They are not color sequences, they are cursor movements. The color sequences end in m, Julia already disables color by default if you use it like this.
Didn’t you also replace cariage returns with new lines?
What I get looks like this (with escape characters replaced by \e and carriage returns replaced by \r):
However, I don’t know why the prompt is repeated twice (but erased right after it’s printed for the first time). An other peculiarity is how the bracketed paste mode sequences (\e?2004h and \e?2004l) encompass both prompts in the first line, but only one in the second line.