1From 1208a632aaeca43f3846116197d645394fbae45d Mon Sep 17 00:00:00 2001
2From: Tim Waugh <twaugh@redhat.com>
3Date: Wed, 27 Aug 2025 09:36:01 +0100
4Subject: [PATCH] Make grepdiff1 test-case pcre-aware
5
6The test case needs a different pattern when configured with/without pcre2.
7
8Fixed: #61
9
10Assisted-by: Cursor
11---
12 tests/grepdiff1/run-test | 11 ++++++++++-
13 1 file changed, 10 insertions(+), 1 deletion(-)
14
15diff --git a/tests/grepdiff1/run-test b/tests/grepdiff1/run-test
16index c4311f8..ebb6023 100755
17--- a/tests/grepdiff1/run-test
18+++ b/tests/grepdiff1/run-test
19@@ -20,7 +20,16 @@ cat << EOF > diff
20 +b
21 EOF
22
23-${GREPDIFF} '\+a' diff 2>errors >index || exit 1
24+# Check if PCRE2 is being used by examining the help output
25+if ${GREPDIFF} --help 2>&1 | grep -q "PCRE regexes are used by default"; then
26+ # PCRE2 is enabled - need to escape the plus sign
27+ PATTERN='\+a'
28+else
29+ # Standard regex - plus sign doesn't need escaping
30+ PATTERN='+a'
31+fi
32+
33+${GREPDIFF} "$PATTERN" diff 2>errors >index || exit 1
34 [ -s errors ] && exit 1
35
36 cat << EOF | cmp - index || exit 1