What does yes $(yes yes) do

command

Wondering what use the yes command might be, I stumbled upon this comment, and tried to execute

yes $(yes yes)

From what I understand, this should simply print out an infinite sequence of yes, but instead it outputs nothing and crashes my graphical terminal after a few seconds. (If I execute it on tty1, I see the login prompt after some time.)

What is happening here?

Best Answer

It should already be enough to run

 echo $(yes yes)

The $(...) runs the inner command until it is finished and captures all its output. - Now as yes runs a long time and generates a lot of output, bash will eventually run out of memory and crash.

Related Question