Opened 3 years ago

Last modified 3 years ago

#63451 new defect

`port search --variant` doesn't find all matching ports

Reported by: ShadSterling (Shad Sterling) Owned by:
Priority: Normal Milestone:
Component: base Version: 2.7.1
Keywords: Cc:
Port:

Description

I noticed this while working on my script to find ports with version numbers in their names so I can ensure everything's up-to-date. I'm trying to add finding ports with variants that specify a specific version of a dependency, such as "nodejs12"

port search --line --variant --regex '^nodejs\d+$' should find at least bamtools, but finds nothing

port search --line --variant --regex '^nodejs$' should find at least thrift, but finds nothing

port search --line --variant --exact nodejs should find at least thrift, but finds nothing

Even the example from the documentation (https://guide.macports.org/chunked/using.html#using.port.search), modified to look for variants, fails:

port search --variant --line --regex '^php\d*$' should find at least dokuwiki, but finds nothing

Change History (4)

comment:1 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Keywords: search variants regex removed

The string that you are matching against when you search with --variants is not the name of each variant individually; it's the names of all variants, in the order in which they're defined in the portfile, concatenated with spaces. (I don't know if that was intentional, and I don't know if it's documented.) So for example:

$ port search --variant --line --regex '^java csharp glib2 php erlang rust nodejs swift universal$'
thrift	0.13.0	devel	framework for scalable cross-language services development

So for example if you're looking for ports that contain a php variant, you can do it with the current search implementation this way:

$ port search --variant --line --regex '(^|\s)php\d*($|\s)'
dokuwiki	2018-04-22b	www	simple to use wiki aimed at documentation projects
librets	1.6.2	devel	RETS client library
mybb	1.8.20	www php	A PHP-based bulletin board / discussion forum system
phpmyadmin	5.1.1	www php databases	A tool written in PHP intended to handle the administration of MySQL over the Web.
phppgadmin	5.1	www databases	phpPgAdmin is a web-based administration tool for PostgreSQL.
phpsh	1.3-20140514	php devel	PHP read-eval-print-loop
redland-bindings	1.0.17.1	www	Redland RDF Language Bindings
roundcubemail	1.1.3	www mail php	Roundcube webmail
squirrelmail	1.4.22	www mail php	A webmail system which accesses mail over IMAP
swig-php	4.0.2	devel	{PHP 7} binding for swig
swig3-php	3.0.12	devel	{PHP 5} binding for swig
thrift	0.13.0	devel	framework for scalable cross-language services development
tiki	19.1	www	php based wiki with lots of extra features
wordpress	5.5.5	www	a state-of-the-art semantic personal publishing platform
zabbix3	3.4.15	net	An open source application and network monitor
zabbix4-frontend	4.0.32	net	An open source application and network monitor
zabbix5-frontend	5.0.14	net	An open source application and network monitor
zabbix42-frontend	4.2.8	net	Obsolete port, replaced by zabbix5
zabbix44-frontend	4.4.10	net	Obsolete port, replaced by zabbix5
ZendFramework1	1.12.20	www lang	A framework for developing PHP web applications
ZendFramework2	2.4.13	www lang	A framework for developing PHP web applications

comment:2 Changed 3 years ago by ShadSterling (Shad Sterling)

That's not mentioned at all in the documentation, but using that the results look right. I'm inclined to use the word-boundary match, e.g. \yphp\d+\y, is there any other quirk that might make that fail?

comment:3 in reply to:  2 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to ShadSterling:

That's not mentioned at all in the documentation, but using that the results look right.

The documentation can always use improvement.

I'm inclined to use the word-boundary match, e.g. \yphp\d+\y, is there any other quirk that might make that fail?

I wasn't familiar with \y but using that instead of (^|\s) and ($|\s) does seem to give the same result and is certainly simpler. I must remember to use \y in the future.

comment:4 Changed 3 years ago by ShadSterling (Shad Sterling)

The documentation can always use improvement.

Is there a howto for submitting a patch to the documentation?

Note: See TracTickets for help on using tickets.