Nimscript: fixes #9246 [backport]

This commit is contained in:
Andreas Rumpf 2018-11-06 21:55:13 +01:00
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": # nim filename.nims is the same as "nim e filename.nims":
if p.key.endswith(".nims"): if p.key.endswith(".nims"):
config.command = "e" config.command = "e"
incl(config.globalOptions, optWasNimscript)
config.projectName = unixToNativePath(p.key) config.projectName = unixToNativePath(p.key)
config.arguments = cmdLineRest(p) config.arguments = cmdLineRest(p)
result = true result = true

View file

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

View file

@ -54,7 +54,8 @@ proc processCmdLine(pass: TCmdLinePass, cmd: string; config: ConfigRef) =
of cmdArgument: of cmdArgument:
if processArgument(pass, p, argsCount, config): break if processArgument(pass, p, argsCount, config): break
if pass == passCmd2: 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) rawMessage(config, errGenerated, errArgsNeedRunOption)
proc handleCmdLine(cache: IdentCache; conf: ConfigRef) = proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =

View file

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

View file

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