[GH-ISSUE #555] Getting weird character when using "--raw" option #304

Closed
opened 2026-02-25 20:33:17 +03:00 by kerem · 4 comments
Owner

Originally created by @PierreMarchand20 on GitHub (Jun 9, 2023).
Original GitHub issue: https://github.com/asciinema/asciinema/issues/555

Describe the bug
When using "--raw" option, the output file can contain weird characters. On my laptop (macOS 12.6.3) or in a docker with ubuntu latest.

To Reproduce
Steps to reproduce the behavior:

  1. asciinema rec --raw test.cast
  2. echo Hello world
  3. exit

image

Expected behavior
I would expect to obtain an output file with

$echo hello world
hello world
$exit
exit

or something similar.

Versions:

  • OS: [macOS 12.6 and Ubuntu 23.04 via docker]
  • asciinema cli: [2.2.0]

Additional context
I have a small python package to script asciinema videos: https://github.com/PierreMarchand20/asciinema_automation and I want to use the output with --raw for regression tests. But when running the CI, the output does not have all these weird letters.

Originally created by @PierreMarchand20 on GitHub (Jun 9, 2023). Original GitHub issue: https://github.com/asciinema/asciinema/issues/555 **Describe the bug** When using "--raw" option, the output file can contain weird characters. On my laptop (macOS 12.6.3) or in a docker with ubuntu latest. **To Reproduce** Steps to reproduce the behavior: 1. asciinema rec --raw test.cast 2. echo Hello world 3. exit ![image](https://github.com/asciinema/asciinema/assets/15056323/56454334-b577-4ef4-8f8b-b58a5a938734) **Expected behavior** I would expect to obtain an output file with ``` $echo hello world hello world $exit exit ``` or something similar. **Versions:** - OS: [macOS 12.6 and Ubuntu 23.04 via docker] - asciinema cli: [2.2.0] **Additional context** I have a small python package to script asciinema videos: https://github.com/PierreMarchand20/asciinema_automation and I want to use the output with --raw for regression tests. But when running the CI, the output does not have all these weird letters.
kerem closed this issue 2026-02-25 20:33:17 +03:00
Author
Owner

@ku1ik commented on GitHub (Jun 9, 2023):

Those characters are so called control characters / escape sequences, which are used for setting colors, cursor movement etc. You don't see them in your terminal when you normally run a program because they're interpreted by your terminal emulator.

Anyway, it works as intended, as it captures full raw output of your program(s).

<!-- gh-comment-id:1584644856 --> @ku1ik commented on GitHub (Jun 9, 2023): Those characters are so called control characters / escape sequences, which are used for setting colors, cursor movement etc. You don't see them in your terminal when you normally run a program because they're interpreted by your terminal emulator. Anyway, it works as intended, as it captures full raw output of your program(s).
Author
Owner

@PierreMarchand20 commented on GitHub (Jun 9, 2023):

Any idea how to remove them ? I thought using PS1="$ " bash --noprofile --norc' would be enough to have nothing else :-/

<!-- gh-comment-id:1584698319 --> @PierreMarchand20 commented on GitHub (Jun 9, 2023): Any idea how to remove them ? I thought using `PS1="$ " bash --noprofile --norc'` would be enough to have nothing else :-/
Author
Owner

@ku1ik commented on GitHub (Jun 10, 2023):

bash, even with most basic config, still produces esc sequences. If you want text only you need to look for a tool which strips non-text characters. I don't know one but I'm sure someone created something like this.

<!-- gh-comment-id:1585596393 --> @ku1ik commented on GitHub (Jun 10, 2023): bash, even with most basic config, still produces esc sequences. If you want text only you need to look for a tool which strips non-text characters. I don't know one but I'm sure someone created something like this.
Author
Owner

@PierreMarchand20 commented on GitHub (Jun 10, 2023):

thank you for your answer, your time and your amazing tool.

For posterity, env -i PS1="$ " bash --noprofile --norc' gets pretty close to a blank shell (see https://stackoverflow.com/a/21391035). env -i removes every environment variables in the new shell, and the extra characters seem to come from the TERM variable.

<!-- gh-comment-id:1585632281 --> @PierreMarchand20 commented on GitHub (Jun 10, 2023): thank you for your answer, your time and your amazing tool. For posterity, `env -i PS1="$ " bash --noprofile --norc'` gets pretty close to a blank shell (see https://stackoverflow.com/a/21391035). `env -i` removes every environment variables in the new shell, and the extra characters seem to come from the `TERM` variable.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asciinema#304
No description provided.