diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2019-01-12 15:26:22 -0800 |
---|---|---|
committer | Timothee Cour <timothee.cour2@gmail.com> | 2019-01-14 17:00:54 -0800 |
commit | 0a8762eb7b4b3c00cb78a40430f51080913a9ee6 (patch) | |
tree | 850fbc31138d8e93dd8af3474e7781b481a435eb /lib/pure | |
parent | e17321aa2429c6bed97bef28a149fd21166b90a2 (diff) | |
download | Nim-0a8762eb7b4b3c00cb78a40430f51080913a9ee6.tar.gz |
fix #9842 #9951: `nim -r` and parseopt.cmdLineRest are now correct
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/parseopt.nim | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/lib/pure/parseopt.nim b/lib/pure/parseopt.nim index eba915604..06f32f032 100644 --- a/lib/pure/parseopt.nim +++ b/lib/pure/parseopt.nim @@ -73,24 +73,6 @@ proc parseWord(s: string, i: int, w: var string, inc(result) when declared(os.paramCount): - proc quote(s: string): string = - if find(s, {' ', '\t'}) >= 0 and s.len > 0 and s[0] != '"': - if s[0] == '-': - result = newStringOfCap(s.len) - var i = parseWord(s, 0, result, {' ', '\t', ':', '='}) - if i < s.len and s[i] in {':','='}: - result.add s[i] - inc i - result.add '"' - while i < s.len: - result.add s[i] - inc i - result.add '"' - else: - result = '"' & s & '"' - else: - result = s - # we cannot provide this for NimRtl creation on Posix, because we can't # access the command line arguments then! @@ -228,11 +210,7 @@ proc next*(p: var OptParser) {.rtl, extern: "npo$1".} = when declared(os.paramCount): proc cmdLineRest*(p: OptParser): TaintedString {.rtl, extern: "npo$1".} = ## retrieves the rest of the command line that has not been parsed yet. - var res = "" - for i in p.idx..<p.cmds.len: - if i > p.idx: res.add ' ' - res.add quote(p.cmds[i]) - result = res.TaintedString + result = p.cmds[p.idx .. ^1].quoteShellCommand.TaintedString proc remainingArgs*(p: OptParser): seq[TaintedString] {.rtl, extern: "npo$1".} = ## retrieves the rest of the command line that has not been parsed yet. |