Skip to content

Instantly share code, notes, and snippets.

@bogen
Last active August 29, 2015 14:04
Show Gist options
  • Save bogen/bab5f91dfeaf24cf68d6 to your computer and use it in GitHub Desktop.
Save bogen/bab5f91dfeaf24cf68d6 to your computer and use it in GitHub Desktop.
os::parseCmdLine fails on multiline strings
import os, macros
macro huh (cmd1, cmd2: expr) : stmt =
let cs = toStrLit(callsite ())
echo "entering ", cs
echo parseCmdLine ($cmd1)
var a = $cmd2
echo a
echo "leaving ", cs, "\n"
discard
macro huh2 () : stmt =
let cs = toStrLit(callsite ())
echo "entering ", cs
echo parseCmdLine ("""1 2 3""")
echo "leaving ", cs, "\n"
discard
macro huh3 () : stmt =
let cs = toStrLit(callsite ())
echo "entering ", cs
echo parseCmdLine ("""
one
two
three
""")
echo "leaving ", cs, "\n"
discard
huh "4 5", dog
huh2
huh3
entering huh "4 5", dog
@[4, 5]
dog
leaving huh "4 5", dog
entering huh2
@[1, 2, 3]
leaving huh2
entering huh3
stack trace: (most recent call last)
cmd.nim(22) huh3
lib/nimrod/pure/os.nim(1450) parseCmdLine
lib/nimrod/pure/os.nim(1450, 10) Error: interpretation requires too many iterations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment