Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 555246

Summary: usex should not source arguments prior to condition evaluation
Product: Portage Development Reporter: Andrew Savchenko <bircoph>
Component: Core - Ebuild SupportAssignee: Portage team <dev-portage>
Status: RESOLVED CANTFIX    
Severity: normal CC: martin
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: emerge --info

Description Andrew Savchenko gentoo-dev 2015-07-18 09:23:50 UTC
Created attachment 407054 [details]
emerge --info

Hi,

The following snippet in the EAPI=5 ebuild:
myconf+=$(usex postgres "--with-pgsql-incdir=$(pg_config --includedir)" "")

causes pg_config to be always executed, even with USE="-postgres", this leads to the following emerge warning:
* QA Notice: command not found:
*
*      /var/tmp/portage/sci-physics/root-5.34.32/temp/environment: line 4007: pg_config: command not found

if dev-db/postgresql is not installed (quite normal for USE="-postgres").

To workaround this issue I use the following solution:
use postgres && myconf+=( --with-pgsql-incdir=$(pg_config --includedir) )

But a proper way will be to fix usex.
Comment 1 Martin Väth 2015-07-18 16:45:55 UTC
This bug makes no sense: It is the shell which evaluates the arguments even before calling usex. The snippet of code you posted is simply broken.
Comment 2 Zac Medico gentoo-dev 2015-07-18 17:03:21 UTC
(In reply to Andrew Savchenko from comment #0)
> To workaround this issue I use the following solution:
> use postgres && myconf+=( --with-pgsql-incdir=$(pg_config --includedir) )

That's a reasonable approach.

> But a proper way will be to fix usex.

As noted in comment #1, it's the shell that evaluates $(pg_config --includedir) before usex is called.
Comment 3 Andrew Savchenko gentoo-dev 2015-07-18 17:47:33 UTC
Ok, thanks for clarification.

Maybe this should be noted in the ebuild 5 manual in order to avoid further confusion?
Comment 4 Zac Medico gentoo-dev 2015-07-18 18:21:40 UTC
(In reply to Andrew Savchenko from comment #3)
> Maybe this should be noted in the ebuild 5 manual in order to avoid further
> confusion?

Well, there's an unlimited number of ways to use shell language incorrectly, and it's beyond the scope of the ebuild 5 manual to document all such possible mistakes. This kind of thing is more relevant in a bash scripting manual/guide/howto.