Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 374791 - tighten 'has' wording so it works with arguments and not whitespace delimited strings
Summary: tighten 'has' wording so it works with arguments and not whitespace delimited...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: PMS/EAPI (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: PMS/EAPI
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-11 08:29 UTC by Brian Harring (RETIRED)
Modified: 2021-09-02 07:31 UTC (History)
1 user (show)

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


Attachments
rough stab at wording. (0001-rewrite-the-text-the-shell-specifically-IFS-is-what-.patch,1.52 KB, text/plain)
2011-07-11 08:30 UTC, Brian Harring (RETIRED)
Details
portage fix. (0001-restore-old-needle-haystack-has-implementation-that-.patch,799 bytes, patch)
2011-07-11 08:34 UTC, Brian Harring (RETIRED)
Details | Diff
follow suit in eclass/tests/ (eclass-tests.patch,394 bytes, patch)
2011-07-11 18:26 UTC, Samuli Suominen (RETIRED)
Details | Diff
Patch for eclass/tests/ (eclass-tests-v2.patch,395 bytes, patch)
2011-07-11 18:58 UTC, Samuli Suominen (RETIRED)
Details | Diff
pkg-mgr-commands.tex: Update description of text list functions (0001-pkg-mgr-commands.tex-Update-description-of-text-list.patch,1.02 KB, patch)
2021-08-31 10:44 UTC, Ulrich Müller
Details | Diff

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