[Buildbot-devel] setting environment variables in build steps

Brian Warner warner-buildbot at lothar.com
Sat Dec 8 21:02:09 UTC 2007


> Hrm. Right, reading helps. backticks is shell expansion stuff, that
> should only work if you do
> 
> command = "make check ALF_LIBRARY_PATH=`pwd`/lib"
> 
> The fact that the list syntax doesn't go through the shell is actually
> documented,
> http://buildbot.net/repos/release/docs/buildbot.html#ShellCommand.
> The wording sounds a bit "the other way around", as you really *want*
> the shell to kick in.

Yeah, this list-vs-string difference in behavior is intentional.

Specifying your command arguments as a pure list of argv elements means the
shell is not going to try to be clever and re-interpret those arguments in
any way. This lets you pass shell metacharacters (including spaces!) as
arguments without playing the losing battle of quoting. There are hundreds of
security holes and unexpected limitations that result from quoting problems,
and they're viciously hard to get right. So if you don't really need anything
special from the shell, stick with the list form of command=.

On the other hand, if you actually do need the shell to get involved, you
have to think about the quoting issues, and give command= a single string.
The argv list that actually gets passed to execve() will be ["/bin/sh", "-c",
"YOURSTRING"], and then you can put whatever you want to in it (backticks,
output redirection, glob patterns, etc). Be careful about allowing
interpolated strings, though (including WithProperties): if you interpolate
an unquoted Builder name that has spaces, the command will probably behave
differently than you expected.

cheers,
 -Brian




More information about the devel mailing list