Getting weird character when using "--raw" option
PierreMarchand20 opened this issue · 4 comments
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:
- asciinema rec --raw test.cast
- echo Hello world
- exit
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.
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).
Any idea how to remove them ? I thought using PS1="$ " bash --noprofile --norc'
would be enough to have nothing else :-/
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.
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.