Live data from Hacker News

What typing ^D does on Unix (2009)

utcc.utoronto.ca

161–162 of 162 posts

Re: What typing ^D does on Unix (2009)

#161

Earlier quoted context omitted.

Shells that want to implement features like tab completion or more elaborate line editing than the basics, which only provide for deleting the last character, word, or line (using Backspace/^W/^U) need to put the terminal into raw mode when reading the user's command line so they can bypass the basic line editing that the terminal provides (called "cooked mode"). However, you can write a shell that doesn't do this. I…

I didn't realize Dash uses cooked mode. That's actually kind of surprising; every other shell I've used always uses raw mode to give them more control over line editing. Is Dash just trying to be as minimalistic as possible?

Dash is really minimalistic. In its default mode, this is the only call to ioctl it makes on standard input according to strace:

    ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
Notice that it's merely calling TCGETS and that icanon is set, which means the "canonical input" mode with the default ^W/^U keybindings is enabled. Bash disables icanon so that it can enable line editing. Interestingly, dash seems to have vi and emacs editing modes, but they don't seem to cause dash to enter raw mode, so I'm not sure they do anything.

Re: What typing ^D does on Unix (2009)

#162

Earlier quoted context omitted.

I don't - and in fact I finally got around to creating a HN account in order to ask you. Googling that just leads me back to this discussion. What's it from?

It's parodying "the TELNET song," by Guy L. Steele.

For more information: http://wonderingminstrels.blogspot.com/2004/01/telnet-song-g...

If you have an ACM subscription, the sheet music was published in Communications of the ACM (Volume 27, Issue 4; April 1984): http://dl.acm.org/citation.cfm?id=1035691

Post reply on HN