diff --git a/INSTALL.md b/INSTALL.md index 24d33a9c..6dff9bb3 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -143,11 +143,14 @@ Environment variables to be set during compile time [config file](build/configDefault.nims#L70) ), can be passed one at a time using `env:FOO=BAR`. See the [examples](#configuration-examples) below. -The full set can also be passed as a Nim seqeunce using the -syntax `envs:'@["FOO=BAR","FOO2=BAR2"]'`. -Preserving the double quotes (by using single quotes here, or backslashes) -is important in this case. -For the single arguments (`env:FOO=BAR`) the double quotes will be added +The full set can also be passed as a Nim seqeunce of strings using the +syntax `envs:'@["FOO=BAR","FOO2=BAR2","FOO3_WITH_SPACE_QUOTES=BAR3 \"IN QUOTES\""]'`. +The third one defines an environment variable with name `FOO3_WITH_SPACE_QUOTES` and +its content `BAR3 "IN QUOTES"`. +The single quotes above prevent shell from interpreting the Nim expression, +which uses double quotes to denote Nim strings. +And the backslashes preserve the double quotes in Nim strings. +For the single arguments (`env:FOO=BAR`) the double quotes will be added by Nim so are unnecessary. Details on the Nim compiler options can be found diff --git a/build/configBase.nims b/build/configBase.nims index 653893ca..7d76b344 100644 --- a/build/configBase.nims +++ b/build/configBase.nims @@ -62,7 +62,7 @@ proc getNimFlags*(fo: flagsOpts): seq[string] = if v=="": defargs.add "--" & key else: - defargs.add "--" & key & ":\"" & v & "\"" + defargs.add "--" & key & ":" & quoteShell v else: if key.len>=7 and key[0..6]!="warning": # warnings don't seem to work here switch(key, v) diff --git a/build/configDefault.nims b/build/configDefault.nims index 348afaa8..61674728 100644 --- a/build/configDefault.nims +++ b/build/configDefault.nims @@ -66,7 +66,7 @@ chromaDir = "" gridDir = "" # seq of extra environment variables to define during build -# e.g. @["OMPI_CXX=foo","BAR=1"] +# e.g. @["OMPI_CXX=foo","BAR=1","ENV_WITH_SPACE_QUOTES=SPACE \"WITH QUOTES\""] envs = @[] # seq of extra arguments for Nim during build