[seed] Make the repl use the sandbox module, so as to not expose the repl's globals inside the repl
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] Make the repl use the sandbox module, so as to not expose the repl's globals inside the repl
- Date: Thu, 7 May 2009 03:50:06 -0400 (EDT)
commit ee0207fad1efb26fbd1d48e9a2ac811fb761dbd5
Author: Robert Carr <racarr svn gnome org>
Date: Thu May 7 03:50:01 2009 -0400
Make the repl use the sandbox module, so as to not expose the repl's globals inside the repl
---
examples/repl.js | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/examples/repl.js b/examples/repl.js
index 90990c4..113bcf5 100755
--- a/examples/repl.js
+++ b/examples/repl.js
@@ -1,9 +1,13 @@
#!/usr/bin/env seed
readline = imports.readline;
+sandbox = imports.sandbox;
var lastLastLength = '-1';
+context = new sandbox.Context();
+context.add_globals();
+
bind_cr = function(){
var buffer = readline.buffer();
if (buffer.length == lastLastLength)
@@ -20,13 +24,18 @@ bind_cr = function(){
lastLastLength = buffer.length;
}
+bind_tab = function(){
+ os.write(1, "\t");
+}
+
readline.bind('\n', bind_cr);
readline.bind('\r', bind_cr);
+readline.bind('\t', bind_tab);
while(1){
try{
item = readline.readline("> ");
- Seed.print(eval(item));
+ Seed.print(context.eval(item));
}
catch(e){
Seed.print(e.name + " " + e.message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]