t: convert egrep usage to "grep -E"
Despite POSIX states that: > The old egrep and fgrep commands are likely to be supported for many > years to come as implementation extensions, allowing historical > applications to operate unmodified. GNU grep 3.8 started to warn[1]: > The egrep and fgrep commands, which have been deprecated since > release 2.5.3 (2007), now warn that they are obsolescent and should > be replaced by grep -E and grep -F. Prepare for their removal in the future. [1]: https://lists.gnu.org/archive/html/info-gnu/2022-09/msg00001.html Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Đoàn Trần Công Danh committed
Sep 21, 2022 at 20:02 UTC
81580fa06d85ef519a46b0b225cebfe71c168a37
11 files changed
+29
-29
t/perf/run
+2
-2
@@ -232,10 +232,10 @@ then
232
)
233
elif test -n "$GIT_PERF_SUBSECTION"
234
then
235
- egrep "^$GIT_PERF_SUBSECTION\$" "$TEST_RESULTS_DIR"/run_subsections.names >/dev/null ||
235
+ grep -E "^$GIT_PERF_SUBSECTION\$" "$TEST_RESULTS_DIR"/run_subsections.names >/dev/null ||
236
die "subsection '$GIT_PERF_SUBSECTION' not found in '$GIT_PERF_CONFIG_FILE'"
237
238
- egrep "^$GIT_PERF_SUBSECTION\$" "$TEST_RESULTS_DIR"/run_subsections.names | while read -r subsec
238
+ grep -E "^$GIT_PERF_SUBSECTION\$" "$TEST_RESULTS_DIR"/run_subsections.names | while read -r subsec
239
do
240
(
241
GIT_PERF_SUBSECTION="$subsec"
t/t1304-default-acl.sh
+2
-2
@@ -18,7 +18,7 @@ test_expect_success 'checking for a working acl setup' '
18
if setfacl -m d:m:rwx -m u:root:rwx . &&
19
getfacl . | grep user:root:rwx &&
20
touch should-have-readable-acl &&
21
- getfacl should-have-readable-acl | egrep "mask::?rw-"
21
+ getfacl should-have-readable-acl | grep -E "mask::?rw-"
22
then
23
test_set_prereq SETFACL
24
fi
@@ -34,7 +34,7 @@ check_perms_and_acl () {
34
getfacl "$1" > actual &&
35
grep -q "user:root:rwx" actual &&
36
grep -q "user:${LOGNAME}:rwx" actual &&
37
- egrep "mask::?r--" actual > /dev/null 2>&1 &&
37
+ grep -E "mask::?r--" actual > /dev/null 2>&1 &&
38
grep -q "group::---" actual || false
39
}
40
t/t3702-add-edit.sh
+1
-1
@@ -100,7 +100,7 @@ EOF
100
101
echo "#!$SHELL_PATH" >fake-editor.sh
102
cat >> fake-editor.sh <<\EOF
103
-egrep -v '^index' "$1" >orig-patch &&
103
+grep -E -v '^index' "$1" >orig-patch &&
104
mv -f patch "$1"
105
EOF
106
t/t4014-format-patch.sh
+4
-4
@@ -1457,7 +1457,7 @@ append_signoff()
1457
C=$(git commit-tree HEAD^^{tree} -p HEAD) &&
1458
git format-patch --stdout --signoff $C^..$C >append_signoff.patch &&
1459
sed -n -e "1,/^---$/p" append_signoff.patch |
1460
- egrep -n "^Subject|Sign|^$"
1460
+ grep -E -n "^Subject|Sign|^$"
1461
}
1462
1463
test_expect_success 'signoff: commit with no body' '
@@ -2274,10 +2274,10 @@ test_expect_success 'format-patch --base with --attach' '
2274
test_expect_success 'format-patch --attach cover-letter only is non-multipart' '
2275
test_when_finished "rm -fr patches" &&
2276
git format-patch -o patches --cover-letter --attach=mimemime --base=HEAD~ -1 &&
2277
- ! egrep "^--+mimemime" patches/0000*.patch &&
2278
- egrep "^--+mimemime$" patches/0001*.patch >output &&
2277
+ ! grep -E "^--+mimemime" patches/0000*.patch &&
2278
+ grep -E "^--+mimemime$" patches/0001*.patch >output &&
2279
test_line_count = 2 output &&
2280
- egrep "^--+mimemime--$" patches/0001*.patch >output &&
2280
+ grep -E "^--+mimemime--$" patches/0001*.patch >output &&
2281
test_line_count = 1 output
2282
'
2283
t/t5320-delta-islands.sh
+1
-1
@@ -134,7 +134,7 @@ test_expect_success 'island core places core objects first' '
134
repack -adfi &&
135
git verify-pack -v .git/objects/pack/*.pack |
136
cut -d" " -f1 |
137
- egrep "$root|$two" >actual &&
137
+ grep -E "$root|$two" >actual &&
138
test_cmp expect actual
139
'
140
t/t7527-builtin-fsmonitor.sh
+9
-9
@@ -939,9 +939,9 @@ test_expect_success CASE_INSENSITIVE_FS 'case insensitive+preserving' '
939
# directories and files that we touched. We may or may not get a
940
# trailing slash on modified directories.
941
#
942
- egrep "^event: abc/?$" ./insensitive.trace &&
943
- egrep "^event: abc/def/?$" ./insensitive.trace &&
944
- egrep "^event: abc/def/xyz$" ./insensitive.trace
942
+ grep -E "^event: abc/?$" ./insensitive.trace &&
943
+ grep -E "^event: abc/def/?$" ./insensitive.trace &&
944
+ grep -E "^event: abc/def/xyz$" ./insensitive.trace
945
'
946
947
# The variable "unicode_debug" is defined in the following library
@@ -983,20 +983,20 @@ test_expect_success !UNICODE_COMPOSITION_SENSITIVE 'Unicode nfc/nfd' '
983
then
984
# We should have seen NFC event from OS.
985
# We should not have synthesized an NFD event.
986
- egrep "^event: nfc/c_${utf8_nfc}/?$" ./unicode.trace &&
987
- egrep -v "^event: nfc/c_${utf8_nfd}/?$" ./unicode.trace
986
+ grep -E "^event: nfc/c_${utf8_nfc}/?$" ./unicode.trace &&
987
+ grep -E -v "^event: nfc/c_${utf8_nfd}/?$" ./unicode.trace
988
else
989
# We should have seen NFD event from OS.
990
# We should have synthesized an NFC event.
991
- egrep "^event: nfc/c_${utf8_nfd}/?$" ./unicode.trace &&
992
- egrep "^event: nfc/c_${utf8_nfc}/?$" ./unicode.trace
991
+ grep -E "^event: nfc/c_${utf8_nfd}/?$" ./unicode.trace &&
992
+ grep -E "^event: nfc/c_${utf8_nfc}/?$" ./unicode.trace
993
fi &&
994
995
# We assume UNICODE_NFD_PRESERVED.
996
# We should have seen explicit NFD from OS.
997
# We should have synthesized an NFC event.
998
- egrep "^event: nfd/d_${utf8_nfd}/?$" ./unicode.trace &&
999
- egrep "^event: nfd/d_${utf8_nfc}/?$" ./unicode.trace
998
+ grep -E "^event: nfd/d_${utf8_nfd}/?$" ./unicode.trace &&
999
+ grep -E "^event: nfd/d_${utf8_nfc}/?$" ./unicode.trace
1000
'
1001
1002
test_done
t/t7701-repack-unpack-unreachable.sh
+2
-2
@@ -35,7 +35,7 @@ test_expect_success '-A with -d option leaves unreachable objects unpacked' '
35
git repack -A -d -l &&
36
# verify objects are packed in repository
37
test 3 = $(git verify-pack -v -- .git/objects/pack/*.idx |
38
- egrep "^($fsha1|$csha1|$tsha1) " |
38
+ grep -E "^($fsha1|$csha1|$tsha1) " |
39
sort | uniq | wc -l) &&
40
git show $fsha1 &&
41
git show $csha1 &&
@@ -49,7 +49,7 @@ test_expect_success '-A with -d option leaves unreachable objects unpacked' '
49
git repack -A -d -l &&
50
# verify objects are retained unpacked
51
test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
52
- egrep "^($fsha1|$csha1|$tsha1) " |
52
+ grep -E "^($fsha1|$csha1|$tsha1) " |
53
sort | uniq | wc -l) &&
54
git show $fsha1 &&
55
git show $csha1 &&
t/t9001-send-email.sh
+4
-4
@@ -1519,7 +1519,7 @@ test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
1519
grep "do not declare a Content-Transfer-Encoding" stdout &&
1520
grep email-using-8bit stdout &&
1521
grep "Which 8bit encoding" stdout &&
1522
- egrep "Content|MIME" msgtxt1 >actual &&
1522
+ grep -E "Content|MIME" msgtxt1 >actual &&
1523
test_cmp content-type-decl actual
1524
'
1525
@@ -1530,7 +1530,7 @@ test_expect_success $PREREQ 'sendemail.8bitEncoding works' '
1530
git send-email --from=author@example.com --to=nobody@example.com \
1531
--smtp-server="$(pwd)/fake.sendmail" \
1532
email-using-8bit >stdout &&
1533
- egrep "Content|MIME" msgtxt1 >actual &&
1533
+ grep -E "Content|MIME" msgtxt1 >actual &&
1534
test_cmp content-type-decl actual
1535
'
1536
@@ -1545,7 +1545,7 @@ test_expect_success $PREREQ 'sendemail.8bitEncoding in .git/config overrides --g
1545
git send-email --from=author@example.com --to=nobody@example.com \
1546
--smtp-server="$(pwd)/fake.sendmail" \
1547
email-using-8bit >stdout &&
1548
- egrep "Content|MIME" msgtxt1 >actual &&
1548
+ grep -E "Content|MIME" msgtxt1 >actual &&
1549
test_cmp content-type-decl actual
1550
'
1551
@@ -1557,7 +1557,7 @@ test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1557
--smtp-server="$(pwd)/fake.sendmail" \
1558
--8bit-encoding=UTF-8 \
1559
email-using-8bit >stdout &&
1560
- egrep "Content|MIME" msgtxt1 >actual &&
1560
+ grep -E "Content|MIME" msgtxt1 >actual &&
1561
test_cmp content-type-decl actual
1562
'
1563
t/t9814-git-p4-rename.sh
+1
-1
@@ -216,7 +216,7 @@ test_expect_success 'detect copies' '
216
# variable exists, which allows admins to disable the "p4 move" command.
217
test_lazy_prereq P4D_HAVE_CONFIGURABLE_RUN_MOVE_ALLOW '
218
p4 configure show run.move.allow >out &&
219
- egrep ^run.move.allow: out
219
+ grep -E ^run.move.allow: out
220
'
221
222
# If move can be disabled, turn it off and test p4 move handling
t/t9815-git-p4-submit-fail.sh
+2
-2
@@ -417,8 +417,8 @@ test_expect_success 'cleanup chmod after submit cancel' '
417
! p4 fstat -T action text &&
418
test_path_is_file text+x &&
419
! p4 fstat -T action text+x &&
420
- ls -l text | egrep ^-r-- &&
421
- ls -l text+x | egrep ^-r-x
420
+ ls -l text | grep -E ^-r-- &&
421
+ ls -l text+x | grep -E ^-r-x
422
)
423
'
424
t/test-lib-functions.sh
+1
-1
@@ -897,7 +897,7 @@ test_path_is_symlink () {
897
test_dir_is_empty () {
898
test "$#" -ne 1 && BUG "1 param"
899
test_path_is_dir "$1" &&
900
- if test -n "$(ls -a1 "$1" | egrep -v '^\.\.?$')"
900
+ if test -n "$(ls -a1 "$1" | grep -E -v '^\.\.?$')"
901
then
902
echo "Directory '$1' is not empty, it contains:"
903
ls -la "$1"