[OE-core] [PATCH] tzcode-native: quote ${CC}

Denys Dmytriyenko denis at denix.org
Fri May 19 18:07:20 UTC 2017


On Fri, May 19, 2017 at 01:37:59AM +0200, Enrico Scholz wrote:
> Denys Dmytriyenko <denis at denix.org> writes:
> 
> >> -EXTRA_OEMAKE += "cc=${CC}"
> >> +EXTRA_OEMAKE += "cc='${CC}'"
> >
> > Should these be double-quotes around ${CC}?
> 
> I wrote it in this way:
> 
> - to 60%, because '' is more correct than "" in this context (see below)
> 
> - to 40%, because "" would clutter code too much and I can not say
>   whether it must be quoted as \", \\" or whether perhaps plain " works
>   too

FWIW, bitbake handles nested quotes properly, no escaping needed:

+EXTRA_OEMAKE += "cc="${CC}""


> A yet more correct solution would be
> 
> | export cc = "${CC}"
> 
> in the recipe (outside of do_*()) and perhaps adding '-e' to EXTRA_OEMAKE.
> 
> 
> This handles additionally the case when 'CC' contains a single quote
> (which causes misbehavior in my patch).
> 
> Double quotes are much more worse because CC must not contain '$', '`'
> or '\\' (which is not uncommon in flags like '-DFOO()=\"bar\"').  In OE,
> it is not expected that these characters are interpreted directly by the
> shell (${CC} is passed properly quoted in the environment).
> 
> But all this does not matter... correct quoting is neglactted in OE and
> bitbake; when you are lucky, commands are written as "foo '%s'" % path.
> But nobody uses functions like 'pipes.quote()' or a non-shell variants
> like subprocess.call(['foo', path]).
> 
> So, you can assume that '${FOO}' expands to the same value like "${FOO}".

Yes, bitbake variables will be expanded properly regardles of the quotes. 
Passing a shell variable may cause problems, but may not be a good practice 
in general.

-- 
Denys



More information about the Openembedded-core mailing list