PageRenderTime 78ms CodeModel.GetById 76ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre3/bsh/commands/run.bsh

#
Unknown | 36 lines | 31 code | 5 blank | 0 comment | 0 complexity | e4b3241355ed12648f578b05a95bd51b MD5 | raw file
 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}