summaryrefslogtreecommitdiff
path: root/tests/pcre-z
blob: 99ebc43cc4e8e1e851d9615cc67b102824643cd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
# Test Perl regex with NUL-separated input
. "${srcdir=.}/init.sh"; path_prepend_ ../src
require_pcre_

REGEX=a

printf "%s\n0" abc def ghi aaa gah | tr 0 \\0 > in

grep -z "$REGEX" in > exp 2>err || fail_ 'Cannot do BRE (grep -z) match.'
compare /dev/null err || fail_ 'stderr not empty on grep -z.'

# Sanity check the output
test "$(grep -cz $REGEX in 2>err)" = 3 \
    || fail_ 'Incorrect BRE (grep -cz) match.'
compare /dev/null err || fail_ 'stderr not empty on grep -cz.'

fail=0
grep -Pz "$REGEX" in > out 2>err || fail=1
compare exp out || fail=1
compare /dev/null err || fail=1

Exit $fail