Code: Select all
set x=%y%
somewhere in my code and the program did not work. I needed hours to find that my editor (TextPad) had left a space at the end of that line which was then appended to x.
Sometimes I saw code like
Code: Select all
set "x=%y%"
which I did not understand and which should be an error according to the specification of the SET statement, which is
Code: Select all
set [variable=[string]]
Q1: Is the reason for that kind of coding with string delimitters just to avoid the problem with trailing spaces?
Q2: What happens really during execution of that statement? Does the command interpreter just throw the apostrophes away? But take the second apostrophe as end-of-line?
Actually I can write
Code: Select all
set "x=any value" and then comments
Q3: Why is that legal?
Q4: Would it not be reasonable, if not compelling, to use that kind of coding always?