Asciinema: Cast contains unwanted exit command

Created on 24 Feb 2018  ·  3Comments  ·  Source: asciinema/asciinema

Hello,

I wondered why an exit is printed after pressing CTRL + D to finish the cast using rec.

redaxmedia@redaxmedia:~$ exit
asciinema: recording finished
asciinema: press <enter> to upload to asciinema.org, <ctrl-c> to save locally

A cast generated by asciinema 1.x.x looks fine - I would like to get rid of it again.

Before

Before

After

After

Most helpful comment

When releasing 2.0 I was aware of this regression, but didn't want to block release because of it. But now is a good time to discuss it.

This is your shell printing exit when you hit ctrl+d btw :)

The previous version of asciinema kept whole recording in memory before saving it to file, and it was easy to detect "exit" in the last recorded frame and throw it away (because asciinema knew it's the last frame). With new version came new file format, which is more real-time, streaming friendly, and it writes to disk in real-time. Due to this when the recording session finishes the "exit" has already been written to a file. And we can't just throw away any "exit" printed to a terminal, we can only remove the final one, because you could have nested bash sessions and this "exit" can be useful information for someone watching that you exited the inner shell.

There are several potential solutions for this:

  1. when recording, keep latest frame in memory and write it to disk when the new one comes, making it a buffer of size of 1 frame - downside here is could cause data loss on crash/terminal close (only 1 frame though),
  2. after closing the file at the end of the session, we could re-open it and filter out final "exit" - would need to be done in a streaming fashion (to not load whole thing in mem), similarly to the solution 1.,
  3. filter it out at playback time instead of rec time - this would require some form of read-ahead for asciinema play .... in terminal, but can be very easily done in web player, which buffers whole recording in mem (that's a separate topic, ideally I'd like to not require whole rec in web browsers mem)

In general I prefer to not modify the source data when recording (change text, change timing, remove frames). Removing final "exit" is removing data from the stream, however it's not something the user really wants so it's fine for me to get rid of it.

Solution 2. seems the simplest to me at the moment.

All 3 comments

When releasing 2.0 I was aware of this regression, but didn't want to block release because of it. But now is a good time to discuss it.

This is your shell printing exit when you hit ctrl+d btw :)

The previous version of asciinema kept whole recording in memory before saving it to file, and it was easy to detect "exit" in the last recorded frame and throw it away (because asciinema knew it's the last frame). With new version came new file format, which is more real-time, streaming friendly, and it writes to disk in real-time. Due to this when the recording session finishes the "exit" has already been written to a file. And we can't just throw away any "exit" printed to a terminal, we can only remove the final one, because you could have nested bash sessions and this "exit" can be useful information for someone watching that you exited the inner shell.

There are several potential solutions for this:

  1. when recording, keep latest frame in memory and write it to disk when the new one comes, making it a buffer of size of 1 frame - downside here is could cause data loss on crash/terminal close (only 1 frame though),
  2. after closing the file at the end of the session, we could re-open it and filter out final "exit" - would need to be done in a streaming fashion (to not load whole thing in mem), similarly to the solution 1.,
  3. filter it out at playback time instead of rec time - this would require some form of read-ahead for asciinema play .... in terminal, but can be very easily done in web player, which buffers whole recording in mem (that's a separate topic, ideally I'd like to not require whole rec in web browsers mem)

In general I prefer to not modify the source data when recording (change text, change timing, remove frames). Removing final "exit" is removing data from the stream, however it's not something the user really wants so it's fine for me to get rid of it.

Solution 2. seems the simplest to me at the moment.

Thanks for your explanation.

I have seen casts were people are using exit over CTRL+D and this is causing two exit being printed. However, I hope this is a valid bug and that someone is going to fix it soon.

Any updates on this? I'm facing the same issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bashfulrobot picture bashfulrobot  ·  11Comments

SR-Lut3t1um picture SR-Lut3t1um  ·  3Comments

omaraboumrad picture omaraboumrad  ·  10Comments

ethanboxx picture ethanboxx  ·  6Comments

ThomasWaldmann picture ThomasWaldmann  ·  3Comments