Moving Up And Down The Stack

The current scope can be changed by the u and d commands. u moves the current scope up, while d moves it down. Interactive variable accesses always refer to the current scope.

dbg5.11> u
dbg5.12> w
 0: expect -D 1 debug-test.exp
 1: p1
*2: p2
 3: p3
 4: set m 0
dbg5.13> set c
4

Both u and d accept an argument representing the number of scopes by which to move. For example, "u 2" moves from scope 2 to scope 0.

dbg5.14> u 2
dbg5.15> w
*0: expect -D 1 debug-test.exp
 1: p1
 2: p2
 3: p3
 4: set m 0

An absolute scope is also accepted in the form of "#" followed by a scope number, such as "#3“.

dbg5.16> u #3
dbg5.17> w
 0: expect -D 1 debug-test.exp
 1: p1
 2: p2
*3: p3
 4: set m 0

When an absolute scope is named, either u or d may be used, irrespective of which direction the new scope lies.

Moving the scope does not affect the next script command that is about to be executed. If a command such as s or n is given, the current scope is automatically reset to wherever is appropriate for execution of the new command.

Get Exploring Expect now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.