tags:

views:

33

answers:

2
SET SS_SOURCE_PROJECT = sausages
@echo SS_SOURCE_PROJECT = %SS_SOURCE_PROJECT%

This isn't working, it just outputs:

SS_SOURCE_PROJECT =

But I am expecting

SS_SOURCE_PROJECT = sausages

This is on WinXP if it matters. What obvious dumb thing am I doing wrong?

+3  A: 

remove spaces:

SET SS_SOURCE_PROJECT=sausages

Yes, batch syntax is terrible.

Stefan Steinegger
s/terrible/exciting/
Tim Robinson
You're my hero!
John
Well, “terrible” on the one side is “easy to implement” on the other side ;-). As far as I know at least one Unix shell also has this specific behavior and yet there it's never called terrible but rather superior. Hm.
Joey
@Johannes: I don't know the unix shell very well, but sometimes I get the feeling that DOS only owns the terrible part of a shell syntax and just left out the superior bit.
Stefan Steinegger
I still have proving Turing-completeness of batch files on my todo list. but yes, there are nicer alternatives. Still, it's fun to write then, for me at least. I don't have as much fun writing shell scripts ;-)
Joey
+2  A: 

To expand on @Stefan's answer, the original code works like this: (note the spaces)

C:\>SET SS_SOURCE_PROJECT = sausages

C:\>echo "%SS_SOURCE_PROJECT %"
" sausages"
Tim Robinson
1+, That's true, I didn't even think about it :-)
Stefan Steinegger