Nimscript: fixes #9246 [backport]

This commit is contained in:
Andreas Rumpf
2018-11-06 21:55:13 +01:00
parent 24902394f7
commit 73c306258b
5 changed files with 6 additions and 2 deletions

View File

@@ -776,6 +776,7 @@ proc processArgument*(pass: TCmdLinePass; p: OptParser;
# nim filename.nims is the same as "nim e filename.nims":
if p.key.endswith(".nims"):
config.command = "e"
incl(config.globalOptions, optWasNimscript)
config.projectName = unixToNativePath(p.key)
config.arguments = cmdLineRest(p)
result = true

View File

@@ -265,6 +265,7 @@ proc mainCommand*(graph: ModuleGraph) =
conf.cmd = cmdInteractive
commandInteractive(graph)
of "e":
incl conf.globalOptions, optWasNimscript
commandEval(graph, mainCommandArg(conf))
of "nop", "help":
# prevent the "success" message:

View File

@@ -54,7 +54,8 @@ proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) =
of cmdArgument:
if processArgument(pass, p, argsCount, config): break
if pass == passCmd2:
if optRun notin config.globalOptions and config.arguments.len > 0 and config.command.normalize != "run":
if {optRun, optWasNimscript} * config.globalOptions == {} and
config.arguments.len > 0 and config.command.normalize notin ["run", "e"]:
rawMessage(config, errGenerated, errArgsNeedRunOption)
proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =

View File

@@ -45,7 +45,7 @@ type # please make sure we have under 32 options
TOptions* = set[TOption]
TGlobalOption* = enum # **keep binary compatible**
gloptNone, optForceFullMake,
optDeadCodeElimUnused, # deprecated, always on
optWasNimscript,
optListCmd, optCompileOnly, optNoLinking,
optCDebug, # turn on debugging information
optGenDynLib, # generate a dynamic library

View File

@@ -123,6 +123,7 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
cbconf setCommand:
conf.command = a.getString 0
let arg = a.getString 1
incl(conf.globalOptions, optWasNimscript)
if arg.len > 0:
conf.projectName = arg
let path =