As a matter of style, it is bad form to reissue a prompt upon a timeout. It is even worse to issue a different prompt. The problem is that the user may have been in the middle of entering a response. Users will wonder if their previous keystrokes have been discarded and should be re-entered (or changed). While terminal drivers usually offer a way to find out this information (typically by pressing ^R), an automated program such as an Expect script may not notice that a new prompt has been issued. If a new prompt is asking a different question than the script is answering, serious problems could result.
In the general sense, there is a race condition (unresolvable timing problem) raised by reprompting, and this can result in problems for humans as well as scripts. There are three strategies which I have outlined below. In each case, there is a gamble that can lose, described by the scenario following it. I will explain the steps in each scenario, italizicing the step at which things go awry.
The program does not discard its input buffer ever. This causes trouble if:
|The user begins to enter a response.|
|The program decides the timeout has expired.|
|The user presses return.|
|The program prints a new prompt.|
|The program reads the user’s old answer.|
|The user is left with a new prompt.|
|The user answers it.|
|The program reads the old answer at the next prompt (and user again answers when program is not listening) or the program flushes the buffer as in scenario ...|