0

I accidentally ran cat on a binary. (It happens).
Usually, I witness a flood of random unicode characters in which I hit Ctrl+C.
Sometimes I hear random bell noises because the file has '\' 'a' characters next to each other.

This time, it changed my entire character mapping (I think):
(image shows part of a cat'd file before hitting ctrl+C and typing ls) enter image description here

The problem is easily fixed, but I'm left wondering what caused this.
What can I type into my terminal to produce the same effect?

If relevant, I'm using gnome-terminal and my shell is zsh.

Trevor Hickey
  • 967
  • 3
  • 9
  • 17

1 Answers1

1

It's probably a terminal escape sequence; you could extract those and print them one-by-one to see if a particular sequence causes the borkage:

#!/usr/bin/env perl
use strict;
use warnings;

# turn off any encoding foo
use open IO => ':raw';

# "slurp" mode for whole file reads
local $/;

# for any STDIN or files given to us...
while (readline) {
    # extract ESC-followed by a number of not-ESC not-NUL characters...
    while (m/(\e[^\e\0]+)/g) {
        printf "what does '%vx' do?\n", $1;
        print $1;
        # is a listing borked or not?
        print qx(ls);
        sleep 1;
    }
}
thrig
  • 34,938