The UNIX shells have a feature called type-ahead that allows you to continue typing while the computer is thinking about something. This is convenient if you have a sequence of commands that need to run in order, and you don't like waiting for the last command to finish before typing the next one.
Basically, type-ahead just means that the shell lets you keep typing, even when it's apparently "busy" (i.e., even when you don't have a prompt). You can even continue typing while the current command (in the command, which just waits:) is spraying data to the screen - although you may find that confusing. Any further commands you type will be executed as soon as the foreground command finishes. The easiest way to demonstrate type-ahead is with the
command does nothing for 25 seconds. Therefore, you
don't see a prompt after pressing RETURN at the end of the
What happens if something goes wrong? You can press your (like CTRL-c) at any time to cancel the foreground job. In this case, UNIX will discard the type-ahead, rather than execute it. (The same goes for CTRL-z, or any other signal the foreground job receives from the terminal. ) This is usually what you want; that is, if you press CTRL-c to terminate the foreground job, you usually don't want to execute any jobs that you've queued up afterward. Type-ahead isn't only good for giving additional commands. If your command takes a long time to start, you can type its input while you're waiting. Here's an example that's about as extreme as you're likely to see. It uses , a program for connecting to a remote host:
I managed to enter my first ftp command and my login name (which I knew ftp would ask for) before ftp started. You probably can't use type-ahead for your password, though I've seen some odd systems on which this would work. Even if it works on your system, you shouldn't try it; ftp hasn't had time to turn keyboard echoing off, so your password will appear on your terminal, where anyone can read it.
Using type-ahead like this takes some guts; you have to know exactly what input your application will want, and when it will want it. But it's also fun in a perverse sense. You will find occasional applications (particularly applications that take over the screen) that don't allow type-ahead. However, there's no way to predict what will and what won't. I've seen some Emacs implementations that would let you start editing the file before the editor "came up" on the screen; I've seen others that wouldn't. [vi almost always lets you type commands as it starts. -JP ]
I have a really terrible way of using type-ahead-I don't recommend it, but it shows what you can do. Rather than use a to search for interesting articles. While I watch pages of grep output scroll by, I start typing a command, using the article numbers that I'm interested in. By the time grep has worked through the whole newsgroup, I've finished the more command, and I'm ready to read the articles that grep told me about. (I didn't say this wasn't perverse. And it's easier on terminals that use a slow data rate.), I often cd to a news directory and use