File: pcre-context

package info (click to toggle)
grep 3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 13,404 kB
  • sloc: ansic: 77,930; sh: 10,347; perl: 567; makefile: 364; awk: 71; sed: 16
file content (36 lines) | stat: -rwxr-xr-x 568 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
# Test Perl regex with context
. "${srcdir=.}/init.sh"; path_prepend_ ../src
require_pcre_

cat >in <<'EOF'
Preceded by 0 empty lines.

Preceded by 1 empty line.


Preceded by 2 empty lines.



Preceded by 3 empty lines.




Preceded by 4 empty lines.

EOF
test $? -eq 0 || framework_failure_

printf '%s\0' \
       'Preceded by 2 empty lines.' \
       'Preceded by 3 empty lines.' \
       'Preceded by 4 empty lines.' >exp || framework_failure_

fail=0

grep -Pzo '(?<=\n\n\n).*' in >out || fail_ 'grep -Pzo failed'
compare exp out || fail=1

Exit $fail