[bitbake-devel] [PATCH 1/3] fetcher: quote filenames given in commands
Enrico Scholz
enrico.scholz at informatik.tu-chemnitz.de
Sat Apr 14 13:20:26 UTC 2012
Richard Purdie <richard.purdie at linuxfoundation.org> writes:
>> Filenames were given as-is to shell commands. This causes problems
>> when names contain characters which have a special meaning.
> ...
> Whilst I understand what you're trying to fix, I'm afraid I don't like
> the patch. I'd prefer to have one way of building these commands, rather
> than two different ones with the shell=isinstance(cmd, basestring)
> check.
ok; one way would be calling of 'pipes.quote()' on every variable
substituting %s. But that's boring, error prone and makes the code
ugly.
Another way might be to declare every command as a sequence with special
objects for shell operations; e.g.
| class ShellOp:
| def __init__(self, op):
| self.op = op
|
| cmd = ['bunzip2', '-d', file, ShellOp('|'), 'tar', 'xf', '-']
In simple case (no ShellOp objects), sequence will be given directly to
Popen() with shell=False. Else, pipes.quote() will be applied on every
string element of the sequence while ShellOp() objects will be kept as
as-is.
> I'd like to find a cleaner approach that doesn't involve runfetchcmd2.
As I wrote in the comment, runfetchcmd2() exists because ${FETCHCMD}
might be defined as
git -c 'url.file://${WORKSPACE_DIR}/avrprog.insteadOf=git://git.somewhere/avrprog.git'
There is no simple way to split it into a sequence (note: there might be
quoted whitespaces in an option).
Enrico
More information about the bitbake-devel
mailing list