Honestly I had no idea what ctrl+d even did, I just knew it was a convenient way for me to close all the REPL programs I use. The fact that it is similar to pressing enter really surprised me, so I wanted to share this knowledge with you :)

  • mina86
    link
    fedilink
    English
    arrow-up
    17
    arrow-down
    1
    ·
    edit-2
    18 hours ago

    It’s not. You keep insisting that ^D doesn’t send EOF and yet:

    $ stty -a | grep eof
    intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
    $ man stty |grep -A1 eof |head -n2
           eof CHAR
                  CHAR will send an end of file (terminate the input)
    

    ^D is the EOF character. The thing is that in C every line of a text file must be terminated by a new-line. And so, when you end a file with ^D without a return, you get funky results.