2

A common workflow for me is to type git log -p then search using / for text to find changes in the history. I'm on OSX, using the default pager:

$ git config --global core.pager
# no output (meaning default pager, less)

When I search, flavors of regexes work, like a.+b, however, I can't seem to make word boundaries work. I've tried all of the following:

<word>
\<word\>
\bword\b
\v<word>

The last one is attemping to mimic Vim's very magic switch, which I don't know if it exists in less but it doesn't error. None of these searches return matches.

I've tried turning off color with git config --global color.ui false (default value auto) but this doesn't seem to have any effect.

This question makes it sound like \< should work? But it doesn't.

My less version:

$ less --version
    less 418
    Copyright (C) 1984-2007 Mark Nudelman
Community
  • 1
  • 1
Andy Ray
  • 30,372
  • 14
  • 101
  • 138

1 Answers1

1

According to the less website FAQ (http://www.greenwoodsoftware.com/less/faq.html) less will either use the operating system regular expressions provided by libc, or will use its own built-in library if requested during build.

My less version is 458. The \< and \> operators work perfectly.

Your options include :-

  1. Check (and possibly update) your libc version. (Mine is libc6-2.19)
  2. Build your own less using more recent libraries or configured to use its internal regular expression handler.

For completeness, Ubuntu 12.04 includes the following versions:

  • less 444
  • libc6-2.15

and the regular expressions work as expected.

Alan Moore
  • 73,866
  • 12
  • 100
  • 156
Dave
  • 3,193
  • 1
  • 16
  • 14
  • I've tried building less from source, but when i use the compiled binary (458) it still appears that \< and \> don't work on OSX. I found this in the FAQ http://www.greenwoodsoftware.com/less/faq.html#searchlt but configuring it with that flag still doesn't make the pattern work :( – Andy Ray Apr 15 '15 at 17:35
  • Can I ask, what version of OSX are you running? I was running Mavericks until yesterday. Now my less no longer supports \< or \>.... Even installing from macports doesn't fix it. – Dave Apr 16 '15 at 23:11
  • I'm running Yosemite 10.10.3 – Andy Ray Apr 17 '15 at 00:22