The suggested answer to observe the output of less --version
didn't address my situation on Solaris 10 -- the first two lines read:
less 436
Copyright (C) 1984-2009 Mark Nudelman
I cannot see an obvious regex library in the list of dynamic dependencies:
$ ldd /usr/bin/less
libcurses.so.1 => /lib/libcurses.so.1
libc.so.1 => /lib/libc.so.1
libm.so.2 => /lib/libm.so.2
/lib/libm/libm_hwcap1.so.2
/platform/sun4v/lib/libc_psr.so.1
man libc
indicates that multiple regex interfaces are offered by the library: regcmp
, re_comp
and regcomp
.
By running elfdump
against the binary, I can see references to the symbol regcomp
:
$ elfdump /usr/bin/less | egrep -i 'posix|pcre|regcmp|re_comp|regcomp|regcomp-local'
[452] 0x0003d6a0 0x00000000 FUNC GLOB D 0 UNDEF regcomp
[452] regcomp
R_SPARC_JMP_SLOT 0x3d6a0 0 .rela.plt regcomp
If this is a link to the regcomp
regex compiler function, then the README-text in the answer from @hek2mgl suggests that this less
binary might use POSIX regexes (or Spencer V8 regexes, if compiled into the binary?).
The man page for regcomp(3C)
reads:
DESCRIPTION
These functions interpret basic and extended regular expres-
sions (described on the regex(5) manual page).
Experimenting with searches in less
, I've discovered that the regex repetition operator {...}
works without backslash escapes. The manpage for regex(5)
on my system defines this as Extended Regular Expression (ERE) syntax.
Lastly, I've found several interesting descriptions of the interfaces of various regex engines, summarised below:
Engine Interface
---------------- --------------------------------
GNU re_compile_pattern() and regex.h
PCRE pcre_compile and pcre.h / pcre2_compile and pcre2.h
POSIX regcomp() and regex.h
Henry Spencer V8 regcomp() and regexp.h
BSD re_comp()
System V regcmp()