简体   繁体   中英

Why when I cat the node directory in `/usr/local/bin` does it unleash cthulhu?

So I was installing node and somehow I ended up in the /user/local/bin folder checking what was there.

I wanted to so a ls | grep node ls | grep node but did a ls | cat node ls | cat node . The node directory then started to show itself in all its glory. I chuckled, laughed, then stopped the cat but that left my terminal looking something like this:

在此输入图像描述

It is easily fixable by exiting the window.

I don't recommend you try it but i've managed to recreate it reliably. Just cat the node directory leave it for a few seconds then cancel it.

My question is what on earth is going on here? AFAIK using cat shouldn't be able to make this stuff happen.

Terminals interpret certain combinations of bytes as commands. This is how command line programs can output colors, or change the cursor position. What you're seeing is the output after one of these commands activated a box drawing character set by accident. You can activate it yourself with echo or printf :

my cool prompt$ printf '\033(0'
└≤ ␌⎺⎺┌ ⎻⎼⎺└⎻├$

To get out of this mess, type reset and press Enter - it will clear the screen and set all settings back to default.

└≤ ␌⎺⎺┌ ⎻⎼⎺└⎻├$ ⎼␊⎽␊├

(..screen clears..)

my cool prompt$

You managed to output the contents of the node executable to the terminal. What happens when you output random octets to the terminal depends on what those characters are and on the terminal. It often leaves the terminal in a state that the user did not really expect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM