Escaping whitespace in variable names

1,634 views
Skip to first unread message

finspin

unread,
Feb 5, 2013, 4:00:12 PM2/5/13
to robotframe...@googlegroups.com
I'm trying to create a global variable called BUILD_NAME by passing parameters to command line from 3rd party software (TeamCity). Some TeamCity variables can contain whitespace. In the example below %TC_BUILD_NAME% gets the value "My Build Name".

pybot --variable BUILD_NAME:%TC_BUILD_NAME% C:/tests.txt  --->  pybot --variable BUILD_NAME:My Build Name C:/tests.txt

This obviously doesn't work because there are spaces in the variable name. I looked into Robot Framework Guide: Escaping Complicated Characters but I'm probably misunderstanding how escaping is supposed to work. I tried to do something like this to replace whitespace with underscores:

pybot --escape space:_ --variable BUILD_NAME:%TC_BUILD_NAME% C:/tests.txt

But the above doesn't work as I would expect. %TC_BUILD_NAME% is still rendered as "My Build Name", with whitespace.

Kevin O.

unread,
Feb 5, 2013, 10:24:42 PM2/5/13
to robotframe...@googlegroups.com
I think you just need to put the whole argument in quotes so the shell doesn't interpret the spaces in TC_BUILD_NAME as argument separators when it is expanded:

pybot --variable "BUILD_NAME:%TC_BUILD_NAME%" C:/tests.txt

I tried that and it worked. That should work as long as you do not have double quotes in the value of TC_BUILD_NAME or some other character sequence the shell thinks is special.

finspin

unread,
Feb 6, 2013, 6:34:41 AM2/6/13
to robotframe...@googlegroups.com
Oh, thanks, it works. What I was doing all the time was putting just the parameter in the quotes (as TeamCity guide suggests) and it didn't work:
Reply all
Reply to author
Forward
0 new messages