I came across a configure script that used this test: echo 'alma,korte,banan' | grep -oEia ',K[^,]+,' and expected the result to be ,korte, That looks fine: -o prints only the matching part from the line -E selects egrep syntax, which allows the + operator -i makes it case-insensitive, so that ,k matches ,K -a makes grep assume the input is ascii, which is a no-op here. However, on 9.3 it prints nothing. On 10.0_RC3, the same. By trying simpler versions, it appears it is the combination -o -i that causes the problem. If you leave out -i, and adjust pattern and input to have matching case, then the test case works. Another simplification, omitting -E and replacing + by *, has no effect. If you use another way to find what substring was matched, by replacing -o with --color=always, you find similar results. Interestingly, this: echo 'alma,korte,banan' | grep -Eia --color=always ',K[^,]+,' does actually print the input line as a match, but nothing in it is coloured as the match. I built (on the 9.3 system) the source from -current src/usr.bin/grep, and there it works. This confused me for a while - then I discovered that this isn't the version in actual use. That's the one in src/external/gpl2/grep. The GNU grep from pkgsrc (I tried grep-3.11) works on this example. So maybe all that is needed is to update our in-tree version. It is GPL 3+, though. The one we have seems to be version 2.5.1a(?), GPL 2+, The CHANGES file from upstream https://git.savannah.gnu.org/git/grep.git lists: * Noteworthy changes in release 2.6 (2010-03-23) [stable] ... grep -i -o would fail to report some matches; grep -i --color, while not missing any line containing a match, would fail to color some matches. related to commit 70e236167c3973fc428d2b5b297218fde9b68e73, committed 2010-03-17 Unfortunately this is a rather large commit, due to multibyte support. I expect that some of the changes are not directly related to this bug, but the parts that clearly are, are still not trivial. So I expect that patching just this bug isn't trivial, and simply importing a recent version from upstream is to be preferred. Ours is very, very old... -Olaf. -- ___ Olaf 'Rhialto' Seibert <rhialto/at/falu.nl> \X/ There is no AI. There is just someone else's work. --I. Rose
Attachment:
signature.asc
Description: PGP signature