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 |
---|
comment:2 follow-up: 3 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 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?
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: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: