The—And Other Flags
In Chapter 3 (p. 72), I mentioned the #! line with "—" at the end. I did not explain it at the time, but most of the scripts so far have used this line. I described the #! earlier in this chapter. Now I will explain "—“. The "—" is a flag to Expect. It says not to interpret any of the script arguments but just to pass them on to the script. This is comparable to saying:
expect—script args
Without the "—“, Expect itself interprets arguments that look likeflags. Arguments that look like flags begin with a "-" and appear before arguments that do not look like flags. What is important here is that after Expect finds an argument that does not look like a flag, then no other argument can be a flag. I will discuss this more later.
Flags that Expect knows about are:
| read the script a line at a time (i.e., unbuffered) |
| execute this command before any in the script |
| read commands from this file |
| print internal (diagnostic) information |
| enable the debugger |
| run interactively |
| do not source |
| do not source |
| read commands from the standard input |
| do not interpret remaining arguments |
Some flags take arguments. These can be run together with the flag itself, but for consistency I always put a space between them. For the sake of accuracy, the term flag includes both the dash, letter, and any arguments.
In the following sections, I will describe each of these flags in detail.