Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move shebang invocation syntax handling further up the command line p…
…rocessing queue. Common command line arguments must not be parsed before handling the shebang invocation syntax.
- Loading branch information
Showing
1 changed file
with
7 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,11 @@ int runDubCommandLine(string[] args) | |
environment["TEMP"] = environment["TEMP"].replace("/", "\\"); | ||
} | ||
|
||
// special single-file package shebang syntax | ||
if (args.length >= 2 && args[1].endsWith(".d")) { | ||
args = args[0] ~ ["run", "-q", "--single", args[1], "--"] ~ args[2 ..$]; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
s-ludwig
Author
Member
|
||
} | ||
|
||
// split application arguments from DUB arguments | ||
string[] app_args; | ||
auto app_args_idx = args.countUntil("--"); | ||
|
@@ -146,15 +151,8 @@ int runDubCommandLine(string[] args) | |
string cmdname; | ||
args = common_args.extractRemainingArgs(); | ||
if (args.length >= 1 && !args[0].startsWith("-")) { | ||
if (args[0].endsWith(".d")) { | ||
cmdname = "run"; | ||
if (app_args.length) app_args = args[1 .. $] ~ "--" ~ app_args; | ||
else app_args = args[1 .. $]; | ||
args = ["-q", "--single", args[0]]; | ||
} else { | ||
cmdname = args[0]; | ||
args = args[1 .. $]; | ||
} | ||
cmdname = args[0]; | ||
args = args[1 .. $]; | ||
} else { | ||
if (options.help) { | ||
showHelp(commands, common_args); | ||
|
Maybe this is a good place to
enforce(Path(args[1]).exists, "Expected a valid D file name, but got: '" ~ args[1] ~ "'.")
?