Is there a best practice as to when variables should be enclosed like set "var=val"
Is it the case that if val contains spaces, enclose it, unless it's using a delayed expansion value:
set "var1=Hello world"
set var2=!var!
?
Using double quotes when setting variables
Moderator: DosItHelp
Re: Using double quotes when setting variables
Your previous posts and code which you solved with double quotes has been removed,
and the answer here is that you can always use double quotes when setting a variable
- they are not part of the variable itself.
If the variable contains double quotes and especially unbalanced double quotes then the best solution depends on the exact details of the situation.
set "var1=Hello world"
set "var2=!var!"
and the answer here is that you can always use double quotes when setting a variable
- they are not part of the variable itself.
If the variable contains double quotes and especially unbalanced double quotes then the best solution depends on the exact details of the situation.
set "var1=Hello world"
set "var2=!var!"