Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 555246 - usex should not source arguments prior to condition evaluation
Summary: usex should not source arguments prior to condition evaluation
Status: RESOLVED CANTFIX
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Ebuild Support (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-18 09:23 UTC by Andrew Savchenko
Modified: 2015-07-18 18:21 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge.info,10.56 KB, text/plain)
2015-07-18 09:23 UTC, Andrew Savchenko
Details

Note You need to log in before you can comment on or make changes to this bug.
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.