<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -239,6 +239,13 @@
 			remoteGlobalIDString = CC4143190F25254200E46669;
 			remoteInfo = &quot;JSTalk Framework&quot;;
 		};
+		CC77FDCE10879C8D00323EE7 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 2A37F4A9FDCFA73011CA2CEA /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = CC5FB7C10F1FDCCC00F4ECC2;
+			remoteInfo = &quot;jstalk command line&quot;;
+		};
 /* End PBXContainerItemProxy section */
 
 /* Begin PBXCopyFilesBuildPhase section */
@@ -823,6 +830,7 @@
 			dependencies = (
 				CC5064E60F4A164D00F4A952 /* PBXTargetDependency */,
 				CC43C12A0F4BBE750044BA41 /* PBXTargetDependency */,
+				CC77FDCF10879C8D00323EE7 /* PBXTargetDependency */,
 			);
 			name = &quot;JSTalk Editor&quot;;
 			productInstallPath = &quot;$(HOME)/Applications&quot;;
@@ -1105,6 +1113,11 @@
 			target = CC4143190F25254200E46669 /* JSTalk Framework */;
 			targetProxy = CC5064E50F4A164D00F4A952 /* PBXContainerItemProxy */;
 		};
+		CC77FDCF10879C8D00323EE7 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = CC5FB7C10F1FDCCC00F4ECC2 /* jstalk command line */;
+			targetProxy = CC77FDCE10879C8D00323EE7 /* PBXContainerItemProxy */;
+		};
 /* End PBXTargetDependency section */
 
 /* Begin PBXVariantGroup section */</diff>
      <filename>jstalk.xcodeproj/project.pbxproj</filename>
    </modified>
    <modified>
      <diff>@@ -173,7 +173,6 @@
     
     @try {
         
-        
         JSTalk *jstalk = [[JSTalk alloc] init];
         
         JSCocoaController *jsController = [jstalk jsController];
@@ -183,6 +182,10 @@
         
         [errorLabel setStringValue:@&quot;&quot;];
         
+        if ([self fileURL]) {
+            [jstalk.env setObject:[self fileURL] forKey:@&quot;scriptURL&quot;];
+        }
+        
         if ([JSTPrefs boolForKey:@&quot;clearConsoleOnRun&quot;]) {
             [self clearConsole:nil];
         }</diff>
      <filename>src/JSTDocument.m</filename>
    </modified>
    <modified>
      <diff>@@ -7,8 +7,17 @@
 //
 
 #import &quot;JSTExtras.h&quot;
+#import &quot;JSTalk.h&quot;
 #import &lt;ScriptingBridge/ScriptingBridge.h&gt;
 
+@implementation JSTalk (JSTExtras)
+
+- (void) exit:(int)termCode {
+    exit(termCode);
+}
+
+@end
+
 @implementation NSApplication (JSTExtras)
 
 - (id)open:(NSString*)pathToFile {</diff>
      <filename>src/JSTExtras.m</filename>
    </modified>
    <modified>
      <diff>@@ -13,15 +13,17 @@
     id _printController;
     id _errorController;
     JSCocoaController *_jsController;
+    NSMutableDictionary *_env;
 }
 
 @property (assign) id printController;
 @property (assign) id errorController;
 @property (retain) JSCocoaController *jsController;
+@property (retain) NSMutableDictionary *env;
 
 - (id) executeString:(NSString*) str;
-- (void) pushObject:(id)obj withName:(NSString*)name inController:(JSCocoaController*)jsController;
-- (void) deleteObjectWithName:(NSString*)name inController:(JSCocoaController*)jsController;
+- (void) pushObject:(id)obj withName:(NSString*)name;
+- (void) deleteObjectWithName:(NSString*)name;
 
 - (JSCocoaController*) jsController;
 - (id) callFunctionNamed:(NSString*)name withArguments:(NSArray*)args;</diff>
      <filename>src/JSTalk.h</filename>
    </modified>
    <modified>
      <diff>@@ -23,6 +23,7 @@ static NSMutableArray *JSTalkPluginList;
 @synthesize printController=_printController;
 @synthesize errorController=_errorController;
 @synthesize jsController=_jsController;
+@synthesize env=_env;
 
 + (void) load {
     //debug(@&quot;%s:%d&quot;, __FUNCTION__, __LINE__);
@@ -44,6 +45,7 @@ static NSMutableArray *JSTalkPluginList;
 	self = [super init];
 	if (self != nil) {
         self.jsController = [[[JSCocoaController alloc] init] autorelease];
+        self.env = [NSMutableDictionary dictionary];
 	}
     
 	return self;
@@ -51,7 +53,6 @@ static NSMutableArray *JSTalkPluginList;
 
 
 - (void)dealloc {
-    debug(@&quot;%s:%d&quot;, __FUNCTION__, __LINE__);
     
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     
@@ -62,6 +63,9 @@ static NSMutableArray *JSTalkPluginList;
     [_jsController release];
     _jsController = 0x00;
     
+    [_env release];
+    _env = 0x00;
+    
     [super dealloc];
 }
 
@@ -140,9 +144,9 @@ static NSMutableArray *JSTalkPluginList;
     }
 }
 
-- (void) pushObject:(id)obj withName:(NSString*)name inController:(JSCocoaController*)jsController {
+- (void) pushObject:(id)obj withName:(NSString*)name  {
     
-    JSContextRef ctx                = [jsController ctx];
+    JSContextRef ctx                = [_jsController ctx];
     JSStringRef jsName              = JSStringCreateWithUTF8CString([name UTF8String]);
     JSObjectRef jsObject            = [JSCocoaController jsCocoaPrivateObjectInContext:ctx];
     JSCocoaPrivateObject *private   = JSObjectGetPrivate(jsObject);
@@ -153,9 +157,9 @@ static NSMutableArray *JSTalkPluginList;
     JSStringRelease(jsName);  
 }
 
-- (void) deleteObjectWithName:(NSString*)name inController:(JSCocoaController*)jsController {
+- (void) deleteObjectWithName:(NSString*)name {
     
-    JSContextRef ctx                = [jsController ctx];
+    JSContextRef ctx                = [_jsController ctx];
     JSStringRef jsName              = JSStringCreateWithUTF8CString([name UTF8String]);
 
     JSObjectDeleteProperty(ctx, JSContextGetGlobalObject(ctx), jsName, NULL);
@@ -171,8 +175,8 @@ static NSMutableArray *JSTalkPluginList;
     }
     
     str = [JSTPreprocessor preprocessCode:str];
-        
-    [self pushObject:self withName:@&quot;jstalk&quot; inController:_jsController];
+    
+    [self pushObject:self withName:@&quot;jstalk&quot;];
     
     JSValueRef resultRef = 0x00;
     id resultObj = 0x00;
@@ -193,7 +197,7 @@ static NSMutableArray *JSTalkPluginList;
         [JSCocoaFFIArgument unboxJSValueRef:resultRef toObject:&amp;resultObj inContext:[[self jsController] ctx]];
     }
     
-    [self deleteObjectWithName:@&quot;jstalk&quot; inController:_jsController];
+    [self deleteObjectWithName:@&quot;jstalk&quot;];
     
     // this will free up the reference to ourself
     if ([_jsController ctx]) {</diff>
      <filename>src/JSTalk.m</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,26 @@
 #import &quot;JSTListener.h&quot;
 #import &quot;JSTalk.h&quot;
 
+
+@interface JSCErrorHandler : NSObject {
+    
+}
+@end
+
+@implementation JSCErrorHandler
+
+- (void) JSCocoa:(JSCocoaController*)controller hadError:(NSString*)error onLineNumber:(NSInteger)lineNumber atSourceURL:(id)url {
+    
+    NSLog(@&quot;Error line %d, %@&quot;, lineNumber, error);
+    
+    exit(1);
+}
+
+
+@end
+
+
+
 int main(int argc, char *argv[]) {
     
     if (argc &lt; 2) {
@@ -15,8 +35,15 @@ int main(int argc, char *argv[]) {
                                             encoding:NSUTF8StringEncoding
                                                error:nil];
     
+    JSCErrorHandler *eh = [[[JSCErrorHandler alloc] init] autorelease];
+    
     JSTalk *t = [[[JSTalk alloc] init] autorelease];
     
+    JSCocoaController *jsController = [t jsController];
+    jsController.delegate = eh;
+    
+    [t.env setObject:[NSURL fileURLWithPath:[NSString stringWithUTF8String:argv[1]]] forKey:@&quot;scriptURL&quot;];
+    
     if ([s hasPrefix:@&quot;#!&quot;]) {
         
         NSRange r = [s rangeOfString:@&quot;\n&quot;];
@@ -29,4 +56,6 @@ int main(int argc, char *argv[]) {
     [t executeString:s];
     
     [pool release];
+    
+    return 0;
 }</diff>
      <filename>src/jstalkmain.m</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4843fe1ea77931ea3a33943240598993a100d281</id>
    </parent>
  </parents>
  <author>
    <name>August Mueller</name>
    <email>gus@fmnorth.local</email>
  </author>
  <url>http://github.com/ccgus/jstalk/commit/1a4ff63a1f26bbf07241b3ec68ebe03f5e8ee552</url>
  <id>1a4ff63a1f26bbf07241b3ec68ebe03f5e8ee552</id>
  <committed-date>2009-10-19T10:43:51-07:00</committed-date>
  <authored-date>2009-10-19T10:43:51-07:00</authored-date>
  <message>Added support for some sort of JSTalk envirnoment vars, which you can stuff runtime info in.</message>
  <tree>8b451581a67b03ce6061bbf2c0355f2f8918bd43</tree>
  <committer>
    <name>August Mueller</name>
    <email>gus@fmnorth.local</email>
  </committer>
</commit>
