summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/cmdlinehelper.nim8
-rw-r--r--compiler/main.nim15
2 files changed, 12 insertions, 11 deletions
diff --git a/compiler/cmdlinehelper.nim b/compiler/cmdlinehelper.nim
index e1824316a..26320d9cd 100644
--- a/compiler/cmdlinehelper.nim
+++ b/compiler/cmdlinehelper.nim
@@ -13,6 +13,8 @@ import
   options, idents, nimconf, scriptconfig, extccomp, commands, msgs,
   lineinfos, modulegraphs, condsyms, os, pathutils
 
+from strutils import normalize
+
 type
   NimProg* = ref object
     suggestMode*: bool
@@ -72,7 +74,11 @@ proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: Confi
       runNimScriptIfExists(scriptFile)
       # 'nim foo.nims' means to just run the NimScript file and do nothing more:
       if fileExists(scriptFile) and scriptFile == conf.projectFull:
-        return false
+        if conf.command == "":
+          conf.command = "e"
+          return false
+        elif conf.command.normalize == "e":
+          return false
     else:
       if scriptFile != conf.projectFull:
         runNimScriptIfExists(scriptFile)
diff --git a/compiler/main.nim b/compiler/main.nim
index f8ca2ba59..8cd8a52d4 100644
--- a/compiler/main.nim
+++ b/compiler/main.nim
@@ -150,14 +150,6 @@ const evalPasses = [verbosePass, semPass, evalPass]
 proc evalNim(graph: ModuleGraph; nodes: PNode, module: PSym) =
   carryPasses(graph, nodes, module, evalPasses)
 
-proc commandEval(graph: ModuleGraph; exp: string) =
-  if graph.systemModule == nil:
-    interactivePasses(graph)
-    compileSystemModule(graph)
-  let echoExp = "echo \"eval\\t\", " & "repr(" & exp & ")"
-  evalNim(graph, echoExp.parseString(graph.cache, graph.config),
-    makeStdinModule(graph))
-
 proc commandScan(cache: IdentCache, config: ConfigRef) =
   var f = addFileExt(AbsoluteFile mainCommandArg(config), NimExt)
   var stream = llStreamOpen(f, fmRead)
@@ -345,8 +337,11 @@ proc mainCommand*(graph: ModuleGraph) =
     conf.cmd = cmdInteractive
     commandInteractive(graph)
   of "e":
-    incl conf.globalOptions, optWasNimscript
-    commandEval(graph, mainCommandArg(conf))
+    if not fileExists(conf.projectFull):
+      rawMessage(conf, errGenerated, "NimScript file does not exist: " & conf.projectFull.string)
+    elif not conf.projectFull.string.endsWith(".nims"):
+      rawMessage(conf, errGenerated, "not a NimScript file: " & conf.projectFull.string)
+    # main NimScript logic handled in cmdlinehelper.nim.
   of "nop", "help":
     # prevent the "success" message:
     conf.cmd = cmdDump