summary refs log tree commit diff stats
path: root/lib/pure/os.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-07-08 21:48:03 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-07-08 21:48:03 +0200
commit46dffbed7127dfce862ab39ab4a501aca51f6ddc (patch)
treeecb92b513c9659c0c558937bd06cb759ae82a801 /lib/pure/os.nim
parentd94950ef80f2a4f03d3a322a9d2e2c34ab1aba6c (diff)
downloadNim-46dffbed7127dfce862ab39ab4a501aca51f6ddc.tar.gz
minor improvements to os.paramStr
Diffstat (limited to 'lib/pure/os.nim')
-rw-r--r--lib/pure/os.nim5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index b4cbd200c..880d60d4f 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -1429,7 +1429,7 @@ when defined(nimdoc):
   proc paramStr*(i: int): TaintedString {.tags: [ReadIOEffect].} =
     ## Returns the `i`-th `command line argument`:idx: given to the application.
     ##
-    ## `i` should be in the range `1..paramCount()`, the `EInvalidIndex`
+    ## `i` should be in the range `1..paramCount()`, the `IndexError`
     ## exception will be raised for invalid values.  Instead of iterating over
     ## `paramCount() <#paramCount>`_ with this proc you can call the
     ## convenience `commandLineParams() <#commandLineParams>`_.
@@ -1467,7 +1467,8 @@ elif defined(windows):
     tags: [ReadIOEffect].} =
     # Docstring in nimdoc block.
     if isNil(ownArgv): ownArgv = parseCmdLine($getCommandLine())
-    return TaintedString(ownArgv[i])
+    if i < cmdCount and i >= 0: return TaintedString(ownArgv[i])
+    raise newException(IndexError, "invalid index")
 
 elif not defined(createNimRtl) and
   not(defined(posix) and appType == "lib") and