Search code examples
bashutf-8locale

Bash, printing after output on new


Alright, So lately Ive been running into this a couple of times If one would run echo 'G1o=' | base64 -d in a terminal you'd get username@hostname:~$62;9;c

I think it has something to do with the locale , but is it 'normal' behavior that it puts it 'after' the output of a command ?


Solution

  • The base64 G1o= decodes to hex 1B 5a, which is ESC Z. That's the DECID escape-sequence, which back in the days when terminals were not actually part of the computer but rather devices connected through a serial cable, was the way the computer could ask the terminal what it was exactly. (That's not actually a standard; it was a private code implemented by terminals manufactured by DEC; hence DEC IDentification. DEC stands for Digital Equipment Corporation, notable for making what was possibly the first desktop computer, the PDP-8, a machine I had the pleasure of learning to code for when I was a teenager.)

    Oddly, terminal emulators still support this stuff, so if you write ESC-Z to a terminal program, it will respond by telling you what sort of historical terminal it is vaguely pretending to be. For example, if you were to do that in the Linux console, it would respond: ESC [ ? 6 c which is the code for a DEC VT-102.

    (By the way, your terminal emulator is apparently responding ESC [ ? 62;9 c which is the code for a VT-220 with a variety of extended "National Replacement Character" sets -- that's the ;9 part.)