carriage return in environment variable?

N

Nunayadam Bidnez

Here's an interesting one I've been wrestling with for a bit now and
figured it was time to post in a ng

using wmic get /value in a for/do command to set environment variables
results in the resultant environment variables. This causes me to not be
able to use the variables in scripts because when i echo the variable
any variables that have only the carriage return (and no other
characters) results in ECHO is on and thusly the breakage in scripts.

Is there some method of modifier in doing set such that carriage returns
are not passed to variables. I have never seen this before and am about
ready to give up

thanks in advance
 
M

Matthias Tacke

Nunayadam Bidnez said:
Here's an interesting one I've been wrestling with for a bit now and
figured it was time to post in a ng

using wmic get /value in a for/do command to set environment variables
results in the resultant environment variables. This causes me to not be
able to use the variables in scripts because when i echo the variable
any variables that have only the carriage return (and no other
characters) results in ECHO is on and thusly the breakage in scripts.

Is there some method of modifier in doing set such that carriage returns
are not passed to variables. I have never seen this before and am about
ready to give up

thanks in advance

Set can't handle multiline values, but the effect occurs with empte vars.

Simply put a different valid delimiter than a space after the echo.
AFAIK valid delimiters are .:,;/\(+=

set "emptyvar="
echo:%emptyvar%

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top