pkg-info: supplying word boundary in regex
Matthew Seaman
m.seaman at infracaninophile.co.uk
Mon Jan 12 16:52:59 UTC 2015
On 2015/01/12 15:40, parv at pair.com wrote:
> (Running pkg 1.4.4 on FreeBSD 8-STABLE here.)
>
> Could somebody tell me please the syntax for word boundary in regex
> for pkg-info ...
>
> pkg info -x '...'
>
>
> ... ?
>
> The pkg-info manual page says ...
>
> -x, --regex
> Treat pkg-name as a regular expression according to the "modern"
> or "extended" syntax of re_format(7).
>
> ... and re_format man page says ...
>
> There are two special cases= of bracket expressions: the bracket
> expressions `[[:<:]]' and `[[:>:]]' match the null string at the
> beginning and end of a word respectively. A word is defined as a
> sequence of word characters which is neither preceded nor followed
> by word characters. A word character is an alnum character (as
> defined by ctype(3)) or an underscore.
>
> ... then specifying a word boundary as "x[[:>:]]" (to match "x" at the
> end of a "word") causes "Invalid regex" error. For example, to get
> result only for "tex" (avoiding packages with "text" as string in a
> package name[0]) ...
>
> # pkg info -x 'tex[[:>:]]'
> pkg: sqlite error while executing iterator in file \
> pkgdb_iterator.c:905: Invalid regex
Normally I'd suggest trying:
# env DEBUG=4 pkg info -x 'tex[[:>:]]'
which should display exactly what SQL is being run. However it appears
that the error occurs before Sqlite does any querying -- it must be
while compiling the RE.
>
> Does pkg overstate its support for re_format(7) then?
>
>
> - parv
>
>
> [0] Yes, I realize if a name happens to be "text-tex" I would also
> get a result & that would be expected. Common case is that
> packages here have only either "text" or "tex" exclusively in
> the name.
>
There is always "pkg info -x 'tex$' to anchor the RE at the end of a
string. However that doesn't really answer your question.
The re_format(7) support comes straight out of libc -- it's compiled as
a loadable module for sqlite, so that queries of the form:
SELECT foo FROM bar WHERE foo REXEP 'some-re' ;
should be using re_format(7) style REGEXPs. Admittedly, we haven't
tested all the odd corner cases for regular expression syntax. Cn you
raise an issue on github please?
Cheers,
Matthew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 882 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20150112/0ec01541/attachment.sig>
More information about the freebsd-questions
mailing list