source: trunk/j/src/bsh/commands/run.bsh @ 2

Last change on this file since 2 was 2, checked in by piso, 18 years ago

Initial checkin.

File size: 1.3 KB
Line 
1
2bsh.help.run= "usage: Thread run( filename )";
3
4/**
5  Run a command in its own in its own private global namespace and interpeter
6  context.  (kind of like the unix "chroot" for the namespace)
7  The root bsh system object is extended (with the extend() command) and
8  made visible here, so that system info is effectively inherited.
9  Because the root bsh object is extended it is effectively read / copy
10  on write...  e.g. you can change directories in the child context, do
11  imports, etc. and it will not affect the calling context.
12
13  @return Returns the context so that you can gather results.
14  @param runArgument an argument passed to the child context under the
15    name runArgument.  e.g. you might pass in the calling This context
16    from which to draw variables, etc.
17*/
18run( String filename, Object runArgument )
19{
20  // Our local namespace is going to be the new root (global)
21  // make local copies of the system stuff.
22  //
23  // Extend the root system object
24  // this is problematic...  probably need more here...
25  bsh=extend(global.bsh);
26  bsh.help=extend(bsh.help);
27
28  // cut us off... make us the root (global) namespace for this command
29  this.namespace.prune();
30  this.interpreter.source( filename, this.namespace );
31  return this;
32}
33
34run( String filename ) {
35  run( filename, null );
36}
Note: See TracBrowser for help on using the repository browser.