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

Bug 374791

Summary: tighten 'has' wording so it works with arguments and not whitespace delimited strings
Product: Gentoo Hosted Projects Reporter: Brian Harring (RETIRED) <ferringb>
Component: PMS/EAPIAssignee: PMS/EAPI <pms>
Status: RESOLVED FIXED    
Severity: normal CC: dev-portage
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: rough stab at wording.
portage fix.
follow suit in eclass/tests/
Patch for eclass/tests/
pkg-mgr-commands.tex: Update description of text list functions

Description Brian Harring (RETIRED) gentoo-dev 2011-07-11 08:29:03 UTC
See attached patch; current wording implies each argument is split by the function itself, rather than the reality that IFS splitting is done by the shell- and IFS may not be whitespace chars.

I've yet to see an ebuild/eclass relies on the old form, both historically and via scanning the tree 5 minutes ago manually; pkgcore/paludis are implemented this way, portage was till late '06; now it'll accidentally split on a space (meaning has 'ball' 'ball sack' it'll incorrectly return 0 on).

Patches for all attached.
Comment 1 Brian Harring (RETIRED) gentoo-dev 2011-07-11 08:30:10 UTC
Created attachment 279719 [details]
rough stab at wording.

PMS wording clarification.
Comment 2 Brian Harring (RETIRED) gentoo-dev 2011-07-11 08:34:53 UTC
Created attachment 279721 [details, diff]
portage fix.
Comment 3 Ulrich Müller gentoo-dev 2011-07-11 09:42:34 UTC
(In reply to comment #1)
> PMS wording clarification.

There's a typo:
+\item[has] Return the appropiate code silently.
Comment 4 Zac Medico gentoo-dev 2011-07-11 18:19:16 UTC
(In reply to comment #2)
> Created attachment 279721 [details, diff]
> portage fix.

Thanks, that's in git:

http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f8504d36c50bef4c1a982a4b9262d3e8e15f438b
Comment 5 Samuli Suominen (RETIRED) gentoo-dev 2011-07-11 18:26:10 UTC
Created attachment 279787 [details, diff]
follow suit in eclass/tests/

let's follow suit also in eclass/tests/   if this gets passed
Comment 6 Ulrich Müller gentoo-dev 2011-07-11 18:49:48 UTC
(In reply to comment #5)
> Created attachment 279787 [details, diff]
> follow suit in eclass/tests/

+		[[ ${x} == ${needle} ]] && return 0

Shouldn't "${needle}" be double-quoted, to prevent pattern matching?
Comment 7 Zac Medico gentoo-dev 2011-07-11 18:53:53 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > Created attachment 279787 [details, diff]
> > follow suit in eclass/tests/
> 
> +        [[ ${x} == ${needle} ]] && return 0
> 
> Shouldn't "${needle}" be double-quoted, to prevent pattern matching?

I believe so. That's why I tweaked the portage patch to use the posix-compiant [ "${x}" = "${needle}" ] form.
Comment 8 Samuli Suominen (RETIRED) gentoo-dev 2011-07-11 18:58:41 UTC
Created attachment 279795 [details, diff]
Patch for eclass/tests/

as per feedback
Comment 9 Samuli Suominen (RETIRED) gentoo-dev 2011-07-12 14:29:07 UTC
(In reply to comment #8)
> Created attachment 279795 [details, diff]
> Patch for eclass/tests/
> 
> as per feedback

Committed as:

http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/tests/tests-common.sh?r1=1.3&r2=1.4
Comment 10 Ulrich Müller gentoo-dev 2011-07-25 09:45:36 UTC
(In reply to comment #1)
> Created attachment 279719 [details]
> rough stab at wording.
> 
> PMS wording clarification.

This doesn't look right:

+These functions take 2 or more arguments; the second and later arguments are checked to see if they
+exactly match the first argument, returning shell true (0) if found, non-zero if not.

Calling "has" with only one argument is perfectly valid (in which case the argument is tested against an empty list and the function will return 1).
Comment 11 SpanKY gentoo-dev 2011-10-10 21:35:20 UTC
obviously there is a difference in behavior when talking about something like:
    has foo "foo bar"

but does anyone have any cases where this actually makes a difference ?  if not, it seems like sticking with the old wording would be easier ...
Comment 12 Ulrich Müller gentoo-dev 2021-08-31 10:44:58 UTC
Created attachment 736939 [details, diff]
pkg-mgr-commands.tex: Update description of text list functions
Comment 13 Larry the Git Cow gentoo-dev 2021-09-02 07:31:43 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/proj/pms.git/commit/?id=e68df128f8cd3b427168f9a76a655460766e6d70

commit e68df128f8cd3b427168f9a76a655460766e6d70
Author:     Ulrich Müller <ulm@gentoo.org>
AuthorDate: 2021-08-31 16:05:08 +0000
Commit:     Ulrich Müller <ulm@gentoo.org>
CommitDate: 2021-08-31 16:05:08 +0000

    pkg-mgr-commands.tex: Update description of text list functions
    
    Closes: https://bugs.gentoo.org/374791
    Signed-off-by: Ulrich Müller <ulm@gentoo.org>

 pkg-mgr-commands.tex | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)