Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 270658 - PMS and Portage disagree about "usev !foo"
Summary: PMS and Portage disagree about "usev !foo"
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: PMS/EAPI (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: PMS/EAPI
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 563798
  Show dependency tree
 
Reported: 2009-05-21 06:43 UTC by Ulrich Müller
Modified: 2022-04-14 05:24 UTC (History)
1 user (show)

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


Attachments
Proposed fix (0001-Fix-documentation-of-usev.patch,1.25 KB, patch)
2009-05-21 06:53 UTC, Ulrich Müller
Details | Diff
New proposed fix (0001-Fix-documentation-of-usev.patch,1.23 KB, patch)
2009-05-25 05:42 UTC, Ulrich Müller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Müller gentoo-dev 2009-05-21 06:43:09 UTC
PMS documents "usev" as follows:
"The same as use, but also prints the flag name if it is enabled."

Portage behaviour for "usev !foo" is different (and makes more sense):
  - with foo enabled, it is silent
  - with foo disabled, it prints "!foo"
Comment 1 Ulrich Müller gentoo-dev 2009-05-21 06:53:07 UTC
Created attachment 191997 [details, diff]
Proposed fix
Comment 2 Ciaran McCreesh 2009-05-21 13:15:33 UTC
Can we classify Portage's behaviour here as 'clearly silly' and mark it as undefined behaviour in this EAPI and get Portage to fix it in the next?
Comment 3 Ulrich Müller gentoo-dev 2009-05-21 13:48:48 UTC
(In reply to comment #2)
> Can we classify Portage's behaviour here as 'clearly silly' and mark it as
> undefined behaviour in this EAPI and get Portage to fix it in the next?

No.
Comment 4 Ciaran McCreesh 2009-05-21 13:59:04 UTC
Fairly sure we can, since it is clearly silly and nothing's using it anyway.
Comment 5 Ulrich Müller gentoo-dev 2009-05-21 14:03:37 UTC
(In reply to comment #4)
> Fairly sure we can, since it is clearly silly and nothing's using it anyway.

Please explain, what is silly about Portage's behaviour here? Pkgcore does the same, btw. You want "usev !foo" to echo "foo" with USE=foo and be silent with USE=-foo, as current wording in PMS suggests?

If Paludis behaves different, then Paludis is broken and should be fixed.
Comment 6 Ciaran McCreesh 2009-05-21 14:05:27 UTC
The ! is an operator, not part of the flag name. The ! doesn't end up getting displayed for other use functions that accept it, which strongly suggests it's just an oversight.
Comment 7 Ulrich Müller gentoo-dev 2009-05-21 14:16:38 UTC
Here is a table, to make things clear (haven't really tested with Pkgcore and Paludis, only looked at their source code):

   +---------+-----------+-----------+-----------+-----------+
   |         | usev foo  | usev foo  | usev !foo | usev !foo |
   |         | USE=-foo  | USE=foo   | USE=-foo  | USE=foo   |
   +---------+-----------+-----------+-----------+-----------+
   | PMS     | (nothing) | foo       | (nothing) | foo       |
   +---------+-----------+-----------+-----------+-----------+
   | Portage | (nothing) | foo       | !foo      | (nothing) |
   +---------+-----------+-----------+-----------+-----------+
   | Pkgcore | (nothing) | foo       | !foo      | (nothing) |
   +---------+-----------+-----------+-----------+-----------+
   | Paludis | (nothing) | foo       | foo       | (nothing) |
   +---------+-----------+-----------+-----------+-----------+

Looks like all three package managers must be changed, if we follow your suggestion.
Comment 8 Ciaran McCreesh 2009-05-21 14:25:41 UTC
We need to change the 'it' in PMS, at least... It's highly unclear whether the 'it' refers to the flag name, as you read it, or the 'useq', which is what it's supposed to say...
Comment 9 Ulrich Müller gentoo-dev 2009-05-21 14:40:54 UTC
(In reply to comment #8)
> We need to change the 'it' in PMS, at least...

That's what I'm saying. ;-)

> It's highly unclear whether the 'it' refers to the flag name, as you read it,
> or the 'useq', which is what it's supposed to say...

The word "enabled" seems to indicate that the flag itself is meant (but I'm not a native english speaker).

Also the behaviour is not completely undefined, so we do better than this. All package managers print something iff the return value is true.

"The same as use, but prints its argument or the flag name (implementation dependent) if the return value is true."
Comment 10 Ciaran McCreesh 2009-05-21 14:43:56 UTC
Mm, we probably shouldn't be using the term 'true' to refer to a zero exit status. I'd guess "if the condition is met" is clearest.

Still think we should standardise this to never outputting the ! in EAPI 4.
Comment 11 Ulrich Müller gentoo-dev 2009-05-21 15:23:06 UTC
I've scanned the current Portage tree: Nobody is using usev with a negated argument. In old snapshots I've found one example, but concrete output didn't matter for it.

So can we please keep any additional clutter (like needless EAPI differences) out of the specification? The important thing is that something should be printed for true (0) and nothing for false (1).

"The same as use, but prints its argument or the flag name (implementation
dependent) if and only if the condition is met."

(In reply to comment #10)
> Still think we should standardise this to never outputting the ! in EAPI 4.

We can standardise it when someone comes up with a real usage case for printing either "flag" or "!flag".
Comment 12 Ciaran McCreesh 2009-05-21 15:27:06 UTC
The only plausible use case I can come up for for !flag is for a --disable-things= or --without-things= style argument call, which definitely doesn't want the !. I can't think of any possible case for showing the !, since it's not even something you could tell users to do.
Comment 13 Ulrich Müller gentoo-dev 2009-05-21 16:41:23 UTC
Yeah, I'm not going to defend the exclamation mark ... only trying to keep the spec free from needless case distinctions.

Bug 30360 comment #2 shows that the original intention was to print the flag without the exclamation mark.

This was changed (accidentally?) between portage-2.0.50_pre20 and _pre22: <http://sources.gentoo.org/viewcvs.py/gentoo-src/portage/bin/ebuild.sh?r1=1.153&r2=1.154>
Comment 14 Ciaran McCreesh 2009-05-21 16:52:30 UTC
Ok, so back to comment #2 with a slight variation: can we classify this as a Portage bug and clarify the spec?
Comment 15 Ulrich Müller gentoo-dev 2009-05-21 17:17:33 UTC
(In reply to comment #14)
> Ok, so back to comment #2 with a slight variation: can we classify this as a
> Portage bug and clarify the spec?

O.K. with me, if you don't make it an EAPI issue.
@zmedico: Any objections?

The devmanual has a very compact formulation, BTW:
"As use, echoes flagname upon success."
Comment 16 Ulrich Müller gentoo-dev 2009-05-24 22:17:09 UTC
<ulm> zmedico: bug 270658, is it o.k. if we clarify the PMS spec for "usev" to
      say "echoes flagname upon success"?
<zmedico> ulm: yeah, sounds fine
<ulm> zmedico: you are aware that this is not current portage behaviour?
<ulm> so in usev the 'echo "${1}"' should be changed to 'echo "${1#!}"'
<zmedico> is that going to break anything?
<zmedico> we need to check that first
<ulm> zmedico: no, it's not used in the tree
<zmedico> cool, it's fine by me then
Comment 17 Ulrich Müller gentoo-dev 2009-05-25 05:42:42 UTC
Created attachment 192366 [details, diff]
New proposed fix
Comment 18 Ciaran McCreesh 2009-05-27 23:47:56 UTC
I still don't like 'success'. We don't use it anywhere else. How about 'condition is met'?
Comment 19 Ulrich Müller gentoo-dev 2009-05-28 04:59:25 UTC
> How about 'condition is met'?

Fine with me.
Comment 20 Ciaran McCreesh 2009-06-03 19:55:38 UTC
Ok, applied with that tweak, thanks.
Comment 21 Zac Medico gentoo-dev 2009-06-03 20:38:25 UTC
(In reply to comment #16)
> <ulm> so in usev the 'echo "${1}"' should be changed to 'echo "${1#!}"'

This is in svn r13628.
Comment 22 Zac Medico gentoo-dev 2009-08-03 23:02:36 UTC
This is fixed in sys-apps/portage-2.2_rc34.