OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [expect/] [CHANGES.4to5] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
This file describes the changes from Expect 4 to Expect 5.
2
 
3
The changes that people will find most interesting or annoying are as
4
follows.  Some of them may seem rather arbitrary but fix inconsistencies
5
leading to much cleaner coding both internally and externally.
6
 
7
 
8
-- Expect version 5.20 and above is designed to work with Tcl 7.5 and
9
Tk 4.1.  Expect 5.20 and above will not work with earlier versions.
10
 
11
-- Glob-style patterns do longest-possible matches (from the earliest
12
possible position) just like regexps.  Previously, they matched the
13
shortest-possible strings.  However, the documentation didn't actually
14
say this (it didn't say anything)
15
 
16
-- Exact patterns are now supported from expect.  Use the "-ex" flag.
17
Exact patterns work just like those in interact.  No special handling
18
is made of *, ^, etc.
19
 
20
-- The new command "expect_background" registers patterns that are to
21
be tested against spawned process output whenever it appears (i.e.,
22
asynchronously).  This only works in the Tk environment.  The
23
arguments are the same as the expect command.
24
 
25
-- expect_before and expect_after now handle their arguments like
26
expect_background.  Previously, a command such as "expect_before"
27
with no arguments deleted patterns for all spawn ids.  Now, it only
28
deletes patterns for the current spawn id.  Similarly with the "-i"
29
form.
30
 
31
-- expect_background/before/after support an -info flag to query what
32
the current patterns are.  The results are returned in such a way that
33
they can be re-used by a new expect command.
34
 
35
The -info flag must be the first flag in the command.  With no other
36
arguments, it returns the setting for the current spawn id.  With a -i
37
descriptor, information is returned for that spawn id.  The argument
38
-noindirect may be used to suppress indirects which also match a
39
direct spawn id.  Only a single -i specification may be given with
40
-info.  With the argument "-all", all spawn id specifications are
41
reported.
42
 
43
-- There is now a sleep command.  It understands decimal values such as
44
 
45
        sleep .5
46
 
47
Interrupts and other asynchronous events are processed while Expect sleeps.
48
 
49
-- Traps now use Tcl's "Async" support.  This has advantages and
50
disadvantages.  One advantage is that traps have no chance of screwing
51
up the Tcl internals.  One disadvantage is that trap handlers are
52
delayed at certain specific times and places.  For example, a handler
53
cannot occur inside another handler.  While one handler is running,
54
all other handlers are blocked.  This is probably the most noticable
55
place where handlers are blocked.  Others are generally small windows,
56
so you shouldn't notice the delay in executing the handlers.
57
 
58
Several traps are initially defined:
59
 
60
        trap exit {SIGINT SIGTERM}
61
 
62
If you use the -D flag to start the debugger, the following trap is
63
defined:
64
 
65
        trap {exp_debug 1} SIGINT
66
 
67
You can, of course, override these.  In particular, if you have your
68
own "trap exit SIGINT", this will override the debugger trap.  Because
69
SIGINT is tied to exit (see above) by default anyway, you should
70
remove your own "trap exit SIGINT" unless you specifically do not want
71
to be able to get to the debugger by ^C.
72
 
73
If you want to define your own trap on SIGINT but still trap to the
74
debugger when it is running, use:
75
 
76
        if ![exp_debug] {trap mystuff SIGINT}
77
 
78
Alternatively, you can trap to the debugger using some other signal.
79
 
80
The ONEXIT trap is no longer available.  Instead, say "exit -onexit ..."
81
 
82
Traps are now deleted by using the empty ({}) handler.  The current
83
handler is returned if no action is supplied.  With no arguments, trap
84
returns the signal number of the trap command currently being executed.
85
 
86
-- The wait command now returns a four element list if a valid child
87
was waited on.
88
Element 1: pid
89
Element 2: spawn id
90
Element 3: 0 (or -1 if there was an OS error)
91
Element 4: status (or errno if element 3 == -1)
92
 
93
-- expect and interact notes:
94
 
95
The timeout and eof patterns were initially named "-timeout" and
96
"-eof" but have been renamed "timeout" and "eof" to match those of
97
expect.  The ability to define default timeout/eof actions has been
98
removed.  (You can do this more easily by grouping spawn ids.)
99
 
100
expect and interact now support a "null" keyword to match an ASCII 0.
101
send supports -null and -break keywords.
102
 
103
Since a large number of special keywords have been added to interact,
104
a new keyword "-ex" for "exact" was added descriptive of its default
105
treatment of patterns.  This protects the next token from being
106
misinterpreted as a keyword.  The expect command provides "-gl" for
107
"glob" for analogous reasons.
108
 
109
Any string starting with "-" should be protected by the "-ex" or "-gl"
110
flag, even those that are not keywords currently.  (All strings
111
starting with "-" are reserved for future options.)
112
 
113
String start/end indices are no longer written to expect_out and
114
interact_out unless the -indices flag is given.
115
 
116
expect_out(spawn_id) is set to the spawn id associated with the spawn
117
id that produced the last output in an expect command.  For example,
118
you can use this to delete files that have closed, by removing this
119
element from an indirect spawn ids spec.  The same effect is
120
reproducable with interact (and interact_out(spawn_id)) but for
121
efficiency reasons, it requires the -iwrite flag before each pattern.
122
 
123
Expect's -i and interact's -i, -u, -input, and -output flags can now
124
describe a list of spawn ids.  So you can say things like:
125
 
126
        interact -input "$id1 $id2 $id3" .... -output "$id1 $id2" ...
127
 
128
In this case, id1, 2, 3 would be sent to id1, and 2.
129
 
130
The spawn id may be given as a global variable name (called an
131
"indirect spawn id specification"), in which case, the variable
132
contains the list of spawn ids.  Whenever the variable is changed, the
133
new list of spawn ids is automatically used.  This is particularly
134
useful with any long running expect command such as expect_before,
135
expect_after, expect_background, and interact.
136
 
137
The -update flag was removed.  Use indirect spawn ids (see previous
138
paragraph).
139
 
140
-- interact notes:
141
 
142
Interact now support -input and -output flags that provide very
143
flexible means of moving data from/to multiple spawn ids in complex
144
ways (but very quickly).  It is possible to write most expect loops
145
using a simple interact statement.  For instance, the three way
146
interaction inside kibitz (between two users and a process) is written
147
this way:
148
 
149
        interact {
150
                -output $shell
151
                -input $userin eof { . . . } -output $shell
152
                -input $shell -output "$user_spawn_id $userout"
153
        }
154
 
155
-- send command notes:
156
 
157
It is possible to send a break by using the "-break" flag.
158
 
159
Any string starting with "-" should be protected by preceding it with
160
the "--" flag, even those that are not keywords currently.  (All
161
strings starting "-" are reserved for future options.)
162
 
163
-- The spawn command now takes an "-open" flag which in turns takes a
164
Tcl file as an argument.  This lets you treat raw devices, files, and
165
pipelines as spawned processes without using a pty.
166
 
167
This was actually in Expect 4, but I forgot to document it.  Oops!
168
 
169
-- The old "debug" command (which describes what Expect is doing
170
internally) was renamed "exp_internal".  "debug" (and "exp_debug") now
171
invoke the interactive debugger.
172
 
173
-- The new command "stty" now takes over the job of "system stty".  It
174
works much better, allowing POSIX-style redirection to affect other
175
ttys.  It otherwise takes arguments as "system stty" did.
176
 
177
-- The "-tcl" option to "return" has gone away.  (This was dangerous
178
to anyone that actually happened to return the value "-tcl".)
179
Instead, use inter_return.
180
 
181
-- Added exp_timestamp command to produce very fast timestamps.
182
 
183
-- Added exp_pid command to return pid of given spawn id.
184
 
185
-- The close command now takes an argument of "-onexec" with a following
186
 
187
current spawn id from being closed when another process is exec'd or
188
spawn'd.
189
 
190
        close -onexec 0
191
 
192
While "-onexec 1" returns it to the default condition where it will be
193
closed upon exec or spawn.
194
 
195
-- log_user now returns previous value.  It is acceptable to call now,
196
without arguments just to get the value.
197
 
198
-- The following forms are deprecated.  They will be allowed
199
indefinitely but not advertised or supported if they break.
200
 
201
        -eof, -timeout in interact (reason: didn't match expect.
202
                Instead, use eof or timeout.)
203
 
204
        -- in expect or interact (reason: no easier to read.
205
                Instead, use -gl in expect or -ex in interact.)
206
 
207
        continue -expect (reason: when mixing in extensions, you have
208
                to use exp_continue, so -expect becomes irrelevant.
209
                Instead, use exp_continue.)
210
 
211
        getpid (reason: Tcl now supplies same functionality as "pid".
212
                Instead, use pid.)
213
 
214
        expect_version and expect_library (reason: the name implies
215
                they have something to do with the expect command,
216
                which they doesn't.
217
                Instead, use exp_version and exp_library.)
218
 
219
        -timestamp for obtaining tm and ctime in expect and interact
220
                (reason: separate command now exists for this purpose.
221
                Instead, use exp_timestamp.)
222
 
223
        system stty (reason: bad interaction with redirection.
224
                Instead, use stty.)
225
 
226
-- New examples have been added:
227
 
228
"dislocate" lets you disconnect and reconnect to processes.
229
 
230
"tkpasswd" illustrates passwd embedded in a GUI.
231
 
232
They may not be overwhelmingly useful, but run them once to see what
233
they do.  If you ever need to do anything similar, you can look back
234
at them.
235
 
236
"tknewsbiff" pops up a window or plays a audio clip when you have
237
unread news.
238
 
239
-- Changes to the Expect libraries:
240
 
241
The expect-tcl library (libexpectcl.a) has been integrated with the
242
expect library (libexpect.a).  So references to libexpectcl.a should
243
be removed.
244
 
245
The Expect C library now supports buffering, multiplexing, null
246
matching, full buffer matching.  Basically, all of the features in
247
Expect are now in the library.
248
 
249
Buffering and multiplexing has caused the biggest change to the
250
library.  Previously, exp_match contained the entire buffer that
251
matched.  Now exp_match just points to where in the buffer the match
252
started.  exp_buffer points to the beginning of the buffer.
253
Previously, the previous buffer was thrown away at the beginning of
254
each expect function call.  Now, previously unmatched characters are
255
eligible for matching.
256
 
257
To match on different file descriptors, exp_match, exp_match_end,
258
exp_buffer_end must be restored to their previous values.  Initially,
259
they should be zero.
260
 
261
The meaning of timeout == 0 in the Expect library has been changed.
262
See the man page for more info.
263
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.