Giving Feedback Without -echo
In practice I rarely use -echo. If the user really needs feedback, I give it immediately after recognizing that a pattern is being entered. There is no special support for this. Instead, simply use the escape prefix itself as the sole pattern and then pass control to another procedure that carries out the rest of the recognition. Here is an example from a script which uses ~~ to start commands.
interact "~~" cmd
In the cmd procedure, the user can now be directly prompted for commands:
proc cmd {} {
send_user "command (g, p, ? for more): "
expect_user {
"g" get_cmd
"p" put_cmd
"?" help_cmd
"~" {send "~~"}
. . . and so on
}
}
The user now clearly knows what they are dealing with because the prompting is very explicit. There is no way for the user to be confused about echoing because the two-tilde sequence always invokes the cmd procedure, which in turn entirely suspends the interact until the procedure returns.
Note that if the user really intended to enter two tildes and not have them interpreted as a command, another tilde has to be entered. This is a fairly standard and customary inconvenience with interactions that suspend interact commands. This style is identical to that used by the UNIX telnet command when its escape is entered.