diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-08-05 20:19:15 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-08-05 20:19:15 +0200 |
commit | 8882b062e110877bf361241e8f85739a6ee754e6 (patch) | |
tree | 3eb5347d1190ebc1e7b2ad055d278132f46e41cf /lib | |
parent | f23b7e37243036724053b3f6d475c4ac9f577661 (diff) | |
download | Nim-8882b062e110877bf361241e8f85739a6ee754e6.tar.gz |
added selfExe and selfExec for NimScript support
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system/nimscript.nim | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/system/nimscript.nim b/lib/system/nimscript.nim index ad2b154d4..fc6b8c99d 100644 --- a/lib/system/nimscript.nim +++ b/lib/system/nimscript.nim @@ -122,6 +122,10 @@ proc existsDir*(dir: string): bool = ## An alias for ``dirExists``. dirExists(dir) +proc selfExe*(): string = + ## Returns the currently running nim or nimble executable. + builtin + proc toExe*(filename: string): string = ## On Windows adds ".exe" to `filename`, else returns `filename` unmodified. (when defined(windows): filename & ".exe" else: filename) @@ -208,6 +212,15 @@ proc exec*(command: string, input: string, cache = "") {. log "exec: " & command: echo staticExec(command, input, cache) +proc selfExec*(command: string) = + ## Executes an external command with the current nim/nimble executable. + ## ``Command`` must not contain the "nim " part. + let c = selfExe() & " " & command + log "exec: " & c: + if rawExec(c) != 0: + raise newException(OSError, "FAILED: " & c) + checkOsError() + proc put*(key, value: string) = ## Sets a configuration 'key' like 'gcc.options.always' to its value. builtin |