{"thread":{"id":"58474","subject":"[PATCH 0/4] allow grep -E, and remove egrep","startedAt":"2022-09-20T15:50:02Z","lastAt":"2022-09-20T17:52:31Z","messageCount":9,"participants":["Đoàn Trần Công Danh","SZEDER Gábor","Phillip Wood","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"463311","messageId":"cover.1663688697.git.congdanhqx@gmail.com","threadId":"58474","inReplyTo":null,"subject":"[PATCH 0/4] allow grep -E, and remove egrep","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2022-09-20T15:49:12Z","receivedAt":"2022-09-20T15:50:02Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"Despite our CodingGuidelines dictates that grep -E and or grep \\{m,n\\}\nare forbidden. Our code bases uses them all over place.\n\nIn addiion, GNU grep 3.8 started to spit warning about the continuation\nof deprecation process for egrep and fgrep.\n\nThis series aim to allow \"grep -E\" and replace {e,f}grep usage with\n\"grep -{E,F}\"\n\nĐoàn Trần Công Danh (4):\n  CodingGuidelines: allow grep -E\n  t: remove \\{m,n\\} from BRE grep usage\n  t: convert egrep usage to \"grep -E\"\n  t: convert fgrep usage to \"grep -F\"\n\n Documentation/CodingGuidelines       |  2 --\n t/perf/run                           |  4 ++--\n t/t1304-default-acl.sh               |  4 ++--\n t/t3200-branch.sh                    |  6 ++++--\n t/t3305-notes-fanout.sh              |  2 +-\n t/t3404-rebase-interactive.sh        |  6 +++---\n t/t3700-add.sh                       |  2 +-\n t/t3702-add-edit.sh                  |  2 +-\n t/t4014-format-patch.sh              |  8 ++++----\n t/t5320-delta-islands.sh             |  2 +-\n t/t5550-http-fetch-dumb.sh           |  2 +-\n t/t5702-protocol-v2.sh               |  2 +-\n t/t7003-filter-branch.sh             |  4 ++--\n t/t7527-builtin-fsmonitor.sh         | 18 +++++++++---------\n t/t7701-repack-unpack-unreachable.sh |  4 ++--\n t/t9001-send-email.sh                |  8 ++++----\n t/t9133-git-svn-nested-git-repo.sh   |  6 +++---\n t/t9134-git-svn-ignore-paths.sh      |  8 ++++----\n t/t9140-git-svn-reset.sh             |  4 ++--\n t/t9147-git-svn-include-paths.sh     |  8 ++++----\n t/t9814-git-p4-rename.sh             |  2 +-\n t/t9815-git-p4-submit-fail.sh        |  4 ++--\n t/test-lib-functions.sh              |  2 +-\n 23 files changed, 55 insertions(+), 55 deletions(-)\n\n-- \n2.38.0.rc0\n\n"},{"id":"463312","messageId":"4ad1ac9d9b25f2fc5a2ada28cae0413c04b07e21.1663688697.git.congdanhqx@gmail.com","threadId":"58474","inReplyTo":"cover.1663688697.git.congdanhqx@gmail.com","subject":"[PATCH 1/4] CodingGuidelines: allow grep -E","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2022-09-20T15:49:13Z","receivedAt":"2022-09-20T15:50:12Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"Despite forbidden by CodingGuidelines, our usage of 'grep -E' has been\nincreased over the years, and noone has come and complained.\n\nLet's lift the restriction.\n\nSigned-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n---\n Documentation/CodingGuidelines | 2 --\n 1 file changed, 2 deletions(-)\n\ndiff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines\nindex 9fca21cc5f..cb7a367ea0 100644\n--- a/Documentation/CodingGuidelines\n+++ b/Documentation/CodingGuidelines\n@@ -162,8 +162,6 @@ For shell scripts specifically (not exhaustive):\n \n    - We do not use \\{m,n\\};\n \n-   - We do not use -E;\n-\n    - We do not use ? or + (which are \\{0,1\\} and \\{1,\\}\n      respectively in BRE) but that goes without saying as these\n      are ERE elements not BRE (note that \\? and \\+ are not even part\n-- \n2.38.0.rc0\n\n"},{"id":"463313","messageId":"752b12ef1e27d3b69d6aa3734309895082be7886.1663688697.git.congdanhqx@gmail.com","threadId":"58474","inReplyTo":"cover.1663688697.git.congdanhqx@gmail.com","subject":"[PATCH 2/4] t: remove \\{m,n\\} from BRE grep usage","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2022-09-20T15:49:14Z","receivedAt":"2022-09-20T15:50:15Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"\\{m,n\\} is a GNU extension to BRE, and it's forbidden by our\nCodingGuidelines.\n\nChange to fixed strings or ERE.\n\nSigned-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n---\n t/t3200-branch.sh             | 6 ++++--\n t/t3305-notes-fanout.sh       | 2 +-\n t/t3404-rebase-interactive.sh | 6 +++---\n t/t5550-http-fetch-dumb.sh    | 2 +-\n t/t5702-protocol-v2.sh        | 2 +-\n 5 files changed, 10 insertions(+), 8 deletions(-)\n\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex 9723c2827c..f05ac1fe0b 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -201,8 +201,10 @@ test_expect_success 'git branch -M baz bam should succeed when baz is checked ou\n \n test_expect_success 'git branch -M baz bam should add entries to .git/logs/HEAD' '\n \tmsg=\"Branch: renamed refs/heads/baz to refs/heads/bam\" &&\n-\tgrep \" 0\\{40\\}.*$msg$\" .git/logs/HEAD &&\n-\tgrep \"^0\\{40\\}.*$msg$\" .git/logs/HEAD\n+\tzero=\"00000000\" &&\n+\tzero=\"$zero$zero$zero$zero$zero\" &&\n+\tgrep \" $zero.*$msg$\" .git/logs/HEAD &&\n+\tgrep \"^$zero.*$msg$\" .git/logs/HEAD\n '\n \n test_expect_success 'git branch -M should leave orphaned HEAD alone' '\ndiff --git a/t/t3305-notes-fanout.sh b/t/t3305-notes-fanout.sh\nindex 22ffe5bcb9..aa3bb2e308 100755\n--- a/t/t3305-notes-fanout.sh\n+++ b/t/t3305-notes-fanout.sh\n@@ -9,7 +9,7 @@ path_has_fanout() {\n \tpath=$1 &&\n \tfanout=$2 &&\n \tafter_last_slash=$(($(test_oid hexsz) - $fanout * 2)) &&\n-\techo $path | grep -q \"^\\([0-9a-f]\\{2\\}/\\)\\{$fanout\\}[0-9a-f]\\{$after_last_slash\\}$\"\n+\techo $path | grep -q -E \"^([0-9a-f][0-9a-f]/){$fanout}[0-9a-f]{$after_last_slash}$\"\n }\n \n touched_one_note_with_fanout() {\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 688b01e3eb..4f5abb5ad2 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -1244,9 +1244,9 @@ test_expect_success 'short commit ID collide' '\n \t\ttest $colliding_id = \"$(git rev-parse HEAD | cut -c 1-4)\" &&\n \t\tgrep \"^pick $colliding_id \" \\\n \t\t\t.git/rebase-merge/git-rebase-todo.tmp &&\n-\t\tgrep \"^pick [0-9a-f]\\{$hexsz\\}\" \\\n+\t\tgrep -E \"^pick [0-9a-f]{$hexsz}\" \\\n \t\t\t.git/rebase-merge/git-rebase-todo &&\n-\t\tgrep \"^pick [0-9a-f]\\{$hexsz\\}\" \\\n+\t\tgrep -E \"^pick [0-9a-f]{$hexsz}\" \\\n \t\t\t.git/rebase-merge/git-rebase-todo.backup &&\n \t\tgit rebase --continue\n \t) &&\n@@ -1261,7 +1261,7 @@ test_expect_success 'respect core.abbrev' '\n \t\tset_cat_todo_editor &&\n \t\ttest_must_fail git rebase -i HEAD~4 >todo-list\n \t) &&\n-\ttest 4 = $(grep -c \"pick [0-9a-f]\\{12,\\}\" todo-list)\n+\ttest 4 = $(grep -c -E \"pick [0-9a-f]{12,}\" todo-list)\n '\n \n test_expect_success 'todo count' '\ndiff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh\nindex d7cf85ffea..8f182a3cbf 100755\n--- a/t/t5550-http-fetch-dumb.sh\n+++ b/t/t5550-http-fetch-dumb.sh\n@@ -234,7 +234,7 @@ test_expect_success 'http-fetch --packfile' '\n \t\t--index-pack-arg=--keep \\\n \t\t\"$HTTPD_URL\"/dumb/repo_pack.git/$p >out &&\n \n-\tgrep \"^keep.[0-9a-f]\\{16,\\}$\" out &&\n+\tgrep -E \"^keep.[0-9a-f]{16,}$\" out &&\n \tcut -c6- out >packhash &&\n \n \t# Ensure that the expected files are generated\ndiff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh\nindex 5d42a355a8..b33cd4afca 100755\n--- a/t/t5702-protocol-v2.sh\n+++ b/t/t5702-protocol-v2.sh\n@@ -1001,7 +1001,7 @@ test_expect_success 'part of packfile response provided as URI' '\n \tdo\n \t\tgit verify-pack --object-format=$(test_oid algo) --verbose $idx >out &&\n \t\t{\n-\t\t\tgrep \"^[0-9a-f]\\{16,\\} \" out || :\n+\t\t\tgrep -E \"^[0-9a-f]{16,} \" out || :\n \t\t} >out.objectlist &&\n \t\tif test_line_count = 1 out.objectlist\n \t\tthen\n-- \n2.38.0.rc0\n\n"},{"id":"463314","messageId":"3217fcd8547746ee3c00648fa8eeab8c4b88478c.1663688697.git.congdanhqx@gmail.com","threadId":"58474","inReplyTo":"cover.1663688697.git.congdanhqx@gmail.com","subject":"[PATCH 3/4] t: convert egrep usage to \"grep -E\"","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2022-09-20T15:49:15Z","receivedAt":"2022-09-20T15:50:22Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"Despite POSIX states that:\n\n> The old egrep and fgrep commands are likely to be supported for many\n> years to come as implementation extensions, allowing historical\n> applications to operate unmodified.\n\nGNU grep 3.8 started to warn[1]:\n\n> The egrep and fgrep commands, which have been deprecated since\n> release 2.5.3 (2007), now warn that they are obsolescent and should\n> be replaced by grep -E and grep -F.\n\nPrepare for their removal in the future.\n\n[1]: https://lists.gnu.org/archive/html/info-gnu/2022-09/msg00001.html\n\nSigned-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n---\n t/perf/run                           |  4 ++--\n t/t1304-default-acl.sh               |  4 ++--\n t/t3702-add-edit.sh                  |  2 +-\n t/t4014-format-patch.sh              |  8 ++++----\n t/t5320-delta-islands.sh             |  2 +-\n t/t7527-builtin-fsmonitor.sh         | 18 +++++++++---------\n t/t7701-repack-unpack-unreachable.sh |  4 ++--\n t/t9001-send-email.sh                |  8 ++++----\n t/t9814-git-p4-rename.sh             |  2 +-\n t/t9815-git-p4-submit-fail.sh        |  4 ++--\n t/test-lib-functions.sh              |  2 +-\n 11 files changed, 29 insertions(+), 29 deletions(-)\n\ndiff --git a/t/perf/run b/t/perf/run\nindex 33da4d2aba..34115edec3 100755\n--- a/t/perf/run\n+++ b/t/perf/run\n@@ -232,10 +232,10 @@ then\n \t)\n elif test -n \"$GIT_PERF_SUBSECTION\"\n then\n-\tegrep \"^$GIT_PERF_SUBSECTION\\$\" \"$TEST_RESULTS_DIR\"/run_subsections.names >/dev/null ||\n+\tgrep -E \"^$GIT_PERF_SUBSECTION\\$\" \"$TEST_RESULTS_DIR\"/run_subsections.names >/dev/null ||\n \t\tdie \"subsection '$GIT_PERF_SUBSECTION' not found in '$GIT_PERF_CONFIG_FILE'\"\n \n-\tegrep \"^$GIT_PERF_SUBSECTION\\$\" \"$TEST_RESULTS_DIR\"/run_subsections.names | while read -r subsec\n+\tgrep -E \"^$GIT_PERF_SUBSECTION\\$\" \"$TEST_RESULTS_DIR\"/run_subsections.names | while read -r subsec\n \tdo\n \t\t(\n \t\t\tGIT_PERF_SUBSECTION=\"$subsec\"\ndiff --git a/t/t1304-default-acl.sh b/t/t1304-default-acl.sh\nindex 335d3f3211..c69ae41306 100755\n--- a/t/t1304-default-acl.sh\n+++ b/t/t1304-default-acl.sh\n@@ -18,7 +18,7 @@ test_expect_success 'checking for a working acl setup' '\n \tif setfacl -m d:m:rwx -m u:root:rwx . &&\n \t   getfacl . | grep user:root:rwx &&\n \t   touch should-have-readable-acl &&\n-\t   getfacl should-have-readable-acl | egrep \"mask::?rw-\"\n+\t   getfacl should-have-readable-acl | grep -E \"mask::?rw-\"\n \tthen\n \t\ttest_set_prereq SETFACL\n \tfi\n@@ -34,7 +34,7 @@ check_perms_and_acl () {\n \tgetfacl \"$1\" > actual &&\n \tgrep -q \"user:root:rwx\" actual &&\n \tgrep -q \"user:${LOGNAME}:rwx\" actual &&\n-\tegrep \"mask::?r--\" actual > /dev/null 2>&1 &&\n+\tgrep -E \"mask::?r--\" actual > /dev/null 2>&1 &&\n \tgrep -q \"group::---\" actual || false\n }\n \ndiff --git a/t/t3702-add-edit.sh b/t/t3702-add-edit.sh\nindex a1801a8cbd..82bfb2fd2a 100755\n--- a/t/t3702-add-edit.sh\n+++ b/t/t3702-add-edit.sh\n@@ -100,7 +100,7 @@ EOF\n \n echo \"#!$SHELL_PATH\" >fake-editor.sh\n cat >> fake-editor.sh <<\\EOF\n-egrep -v '^index' \"$1\" >orig-patch &&\n+grep -E -v '^index' \"$1\" >orig-patch &&\n mv -f patch \"$1\"\n EOF\n \ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex ad5c029279..de1da4673d 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1457,7 +1457,7 @@ append_signoff()\n \tC=$(git commit-tree HEAD^^{tree} -p HEAD) &&\n \tgit format-patch --stdout --signoff $C^..$C >append_signoff.patch &&\n \tsed -n -e \"1,/^---$/p\" append_signoff.patch |\n-\t\tegrep -n \"^Subject|Sign|^$\"\n+\t\tgrep -E -n \"^Subject|Sign|^$\"\n }\n \n test_expect_success 'signoff: commit with no body' '\n@@ -2274,10 +2274,10 @@ test_expect_success 'format-patch --base with --attach' '\n test_expect_success 'format-patch --attach cover-letter only is non-multipart' '\n \ttest_when_finished \"rm -fr patches\" &&\n \tgit format-patch -o patches --cover-letter --attach=mimemime --base=HEAD~ -1 &&\n-\t! egrep \"^--+mimemime\" patches/0000*.patch &&\n-\tegrep \"^--+mimemime$\" patches/0001*.patch >output &&\n+\t! grep -E \"^--+mimemime\" patches/0000*.patch &&\n+\tgrep -E \"^--+mimemime$\" patches/0001*.patch >output &&\n \ttest_line_count = 2 output &&\n-\tegrep \"^--+mimemime--$\" patches/0001*.patch >output &&\n+\tgrep -E \"^--+mimemime--$\" patches/0001*.patch >output &&\n \ttest_line_count = 1 output\n '\n \ndiff --git a/t/t5320-delta-islands.sh b/t/t5320-delta-islands.sh\nindex 124d47603d..406363381f 100755\n--- a/t/t5320-delta-islands.sh\n+++ b/t/t5320-delta-islands.sh\n@@ -134,7 +134,7 @@ test_expect_success 'island core places core objects first' '\n \t    repack -adfi &&\n \tgit verify-pack -v .git/objects/pack/*.pack |\n \tcut -d\" \" -f1 |\n-\tegrep \"$root|$two\" >actual &&\n+\tgrep -E \"$root|$two\" >actual &&\n \ttest_cmp expect actual\n '\n \ndiff --git a/t/t7527-builtin-fsmonitor.sh b/t/t7527-builtin-fsmonitor.sh\nindex 56c0dfffea..1746d30cf6 100755\n--- a/t/t7527-builtin-fsmonitor.sh\n+++ b/t/t7527-builtin-fsmonitor.sh\n@@ -939,9 +939,9 @@ test_expect_success CASE_INSENSITIVE_FS 'case insensitive+preserving' '\n \t# directories and files that we touched.  We may or may not get a\n \t# trailing slash on modified directories.\n \t#\n-\tegrep \"^event: abc/?$\"       ./insensitive.trace &&\n-\tegrep \"^event: abc/def/?$\"   ./insensitive.trace &&\n-\tegrep \"^event: abc/def/xyz$\" ./insensitive.trace\n+\tgrep -E \"^event: abc/?$\"       ./insensitive.trace &&\n+\tgrep -E \"^event: abc/def/?$\"   ./insensitive.trace &&\n+\tgrep -E \"^event: abc/def/xyz$\" ./insensitive.trace\n '\n \n # The variable \"unicode_debug\" is defined in the following library\n@@ -983,20 +983,20 @@ test_expect_success !UNICODE_COMPOSITION_SENSITIVE 'Unicode nfc/nfd' '\n \tthen\n \t\t# We should have seen NFC event from OS.\n \t\t# We should not have synthesized an NFD event.\n-\t\tegrep    \"^event: nfc/c_${utf8_nfc}/?$\" ./unicode.trace &&\n-\t\tegrep -v \"^event: nfc/c_${utf8_nfd}/?$\" ./unicode.trace\n+\t\tgrep -E    \"^event: nfc/c_${utf8_nfc}/?$\" ./unicode.trace &&\n+\t\tgrep -E -v \"^event: nfc/c_${utf8_nfd}/?$\" ./unicode.trace\n \telse\n \t\t# We should have seen NFD event from OS.\n \t\t# We should have synthesized an NFC event.\n-\t\tegrep \"^event: nfc/c_${utf8_nfd}/?$\" ./unicode.trace &&\n-\t\tegrep \"^event: nfc/c_${utf8_nfc}/?$\" ./unicode.trace\n+\t\tgrep -E \"^event: nfc/c_${utf8_nfd}/?$\" ./unicode.trace &&\n+\t\tgrep -E \"^event: nfc/c_${utf8_nfc}/?$\" ./unicode.trace\n \tfi &&\n \n \t# We assume UNICODE_NFD_PRESERVED.\n \t# We should have seen explicit NFD from OS.\n \t# We should have synthesized an NFC event.\n-\tegrep \"^event: nfd/d_${utf8_nfd}/?$\" ./unicode.trace &&\n-\tegrep \"^event: nfd/d_${utf8_nfc}/?$\" ./unicode.trace\n+\tgrep -E \"^event: nfd/d_${utf8_nfd}/?$\" ./unicode.trace &&\n+\tgrep -E \"^event: nfd/d_${utf8_nfc}/?$\" ./unicode.trace\n '\n \n test_done\ndiff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh\nindex 937f89ee8c..b7ac4f598a 100755\n--- a/t/t7701-repack-unpack-unreachable.sh\n+++ b/t/t7701-repack-unpack-unreachable.sh\n@@ -35,7 +35,7 @@ test_expect_success '-A with -d option leaves unreachable objects unpacked' '\n \tgit repack -A -d -l &&\n \t# verify objects are packed in repository\n \ttest 3 = $(git verify-pack -v -- .git/objects/pack/*.idx |\n-\t\t   egrep \"^($fsha1|$csha1|$tsha1) \" |\n+\t\t   grep -E \"^($fsha1|$csha1|$tsha1) \" |\n \t\t   sort | uniq | wc -l) &&\n \tgit show $fsha1 &&\n \tgit show $csha1 &&\n@@ -49,7 +49,7 @@ test_expect_success '-A with -d option leaves unreachable objects unpacked' '\n \tgit repack -A -d -l &&\n \t# verify objects are retained unpacked\n \ttest 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |\n-\t\t   egrep \"^($fsha1|$csha1|$tsha1) \" |\n+\t\t   grep -E \"^($fsha1|$csha1|$tsha1) \" |\n \t\t   sort | uniq | wc -l) &&\n \tgit show $fsha1 &&\n \tgit show $csha1 &&\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 01c74b8b07..1130ef21b3 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -1519,7 +1519,7 @@ test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '\n \tgrep \"do not declare a Content-Transfer-Encoding\" stdout &&\n \tgrep email-using-8bit stdout &&\n \tgrep \"Which 8bit encoding\" stdout &&\n-\tegrep \"Content|MIME\" msgtxt1 >actual &&\n+\tgrep -E \"Content|MIME\" msgtxt1 >actual &&\n \ttest_cmp content-type-decl actual\n '\n \n@@ -1530,7 +1530,7 @@ test_expect_success $PREREQ 'sendemail.8bitEncoding works' '\n \tgit send-email --from=author@example.com --to=nobody@example.com \\\n \t\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n \t\t\temail-using-8bit >stdout &&\n-\tegrep \"Content|MIME\" msgtxt1 >actual &&\n+\tgrep -E \"Content|MIME\" msgtxt1 >actual &&\n \ttest_cmp content-type-decl actual\n '\n \n@@ -1545,7 +1545,7 @@ test_expect_success $PREREQ 'sendemail.8bitEncoding in .git/config overrides --g\n \tgit send-email --from=author@example.com --to=nobody@example.com \\\n \t\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n \t\t\temail-using-8bit >stdout &&\n-\tegrep \"Content|MIME\" msgtxt1 >actual &&\n+\tgrep -E \"Content|MIME\" msgtxt1 >actual &&\n \ttest_cmp content-type-decl actual\n '\n \n@@ -1557,7 +1557,7 @@ test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '\n \t\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n \t\t\t--8bit-encoding=UTF-8 \\\n \t\t\temail-using-8bit >stdout &&\n-\tegrep \"Content|MIME\" msgtxt1 >actual &&\n+\tgrep -E \"Content|MIME\" msgtxt1 >actual &&\n \ttest_cmp content-type-decl actual\n '\n \ndiff --git a/t/t9814-git-p4-rename.sh b/t/t9814-git-p4-rename.sh\nindex 468767cbf4..2a9838f37f 100755\n--- a/t/t9814-git-p4-rename.sh\n+++ b/t/t9814-git-p4-rename.sh\n@@ -216,7 +216,7 @@ test_expect_success 'detect copies' '\n # variable exists, which allows admins to disable the \"p4 move\" command.\n test_lazy_prereq P4D_HAVE_CONFIGURABLE_RUN_MOVE_ALLOW '\n \tp4 configure show run.move.allow >out &&\n-\tegrep ^run.move.allow: out\n+\tgrep -E ^run.move.allow: out\n '\n \n # If move can be disabled, turn it off and test p4 move handling\ndiff --git a/t/t9815-git-p4-submit-fail.sh b/t/t9815-git-p4-submit-fail.sh\nindex 9779dc0d11..0ca9937de6 100755\n--- a/t/t9815-git-p4-submit-fail.sh\n+++ b/t/t9815-git-p4-submit-fail.sh\n@@ -417,8 +417,8 @@ test_expect_success 'cleanup chmod after submit cancel' '\n \t\t! p4 fstat -T action text &&\n \t\ttest_path_is_file text+x &&\n \t\t! p4 fstat -T action text+x &&\n-\t\tls -l text | egrep ^-r-- &&\n-\t\tls -l text+x | egrep ^-r-x\n+\t\tls -l text | grep -E ^-r-- &&\n+\t\tls -l text+x | grep -E ^-r-x\n \t)\n '\n \ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex c6479f24eb..527a714500 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -897,7 +897,7 @@ test_path_is_symlink () {\n test_dir_is_empty () {\n \ttest \"$#\" -ne 1 && BUG \"1 param\"\n \ttest_path_is_dir \"$1\" &&\n-\tif test -n \"$(ls -a1 \"$1\" | egrep -v '^\\.\\.?$')\"\n+\tif test -n \"$(ls -a1 \"$1\" | grep -E -v '^\\.\\.?$')\"\n \tthen\n \t\techo \"Directory '$1' is not empty, it contains:\"\n \t\tls -la \"$1\"\n-- \n2.38.0.rc0\n\n"},{"id":"463315","messageId":"213412d2f747de7e3b3504630cb6fcc1b96c46c7.1663688697.git.congdanhqx@gmail.com","threadId":"58474","inReplyTo":"cover.1663688697.git.congdanhqx@gmail.com","subject":"[PATCH 4/4] t: convert fgrep usage to \"grep -F\"","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2022-09-20T15:49:16Z","receivedAt":"2022-09-20T15:50:28Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"Despite POSIX states that:\n\n> The old egrep and fgrep commands are likely to be supported for many\n> years to come as implementation extensions, allowing historical\n> applications to operate unmodified.\n\nGNU grep 3.8 started to warn[1]:\n\n> The egrep and fgrep commands, which have been deprecated since\n> release 2.5.3 (2007), now warn that they are obsolescent and should\n> be replaced by grep -E and grep -F.\n\nPrepare for their removal in the future.\n\n[1]: https://lists.gnu.org/archive/html/info-gnu/2022-09/msg00001.html\n\nSigned-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n---\n t/t3700-add.sh                     | 2 +-\n t/t7003-filter-branch.sh           | 4 ++--\n t/t9133-git-svn-nested-git-repo.sh | 6 +++---\n t/t9134-git-svn-ignore-paths.sh    | 8 ++++----\n t/t9140-git-svn-reset.sh           | 4 ++--\n t/t9147-git-svn-include-paths.sh   | 8 ++++----\n 6 files changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/t/t3700-add.sh b/t/t3700-add.sh\nindex 8689b48589..51afbd7b24 100755\n--- a/t/t3700-add.sh\n+++ b/t/t3700-add.sh\n@@ -291,7 +291,7 @@ test_expect_success BSLASHPSPEC \"git add 'fo\\\\[ou\\\\]bar' ignores foobar\" '\n \tgit reset --hard &&\n \ttouch fo\\[ou\\]bar foobar &&\n \tgit add '\\''fo\\[ou\\]bar'\\'' &&\n-\tgit ls-files fo\\[ou\\]bar | fgrep fo\\[ou\\]bar &&\n+\tgit ls-files fo\\[ou\\]bar | grep -F fo\\[ou\\]bar &&\n \t! ( git ls-files foobar | grep foobar )\n '\n \ndiff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\nindex e18a218952..a00cdba049 100755\n--- a/t/t7003-filter-branch.sh\n+++ b/t/t7003-filter-branch.sh\n@@ -49,7 +49,7 @@ test_expect_success 'result is really identical' '\n test_expect_success 'rewrite bare repository identically' '\n \t(git config core.bare true && cd .git &&\n \t git filter-branch branch > filter-output 2>&1 &&\n-\t! fgrep fatal filter-output)\n+\t! grep -F fatal filter-output)\n '\n git config core.bare false\n test_expect_success 'result is really identical' '\n@@ -506,7 +506,7 @@ test_expect_success 'rewrite repository including refs that point at non-commit\n \tgit tag -a -m \"tag to a tree\" treetag $new_tree &&\n \tgit reset --hard HEAD &&\n \tgit filter-branch -f -- --all >filter-output 2>&1 &&\n-\t! fgrep fatal filter-output\n+\t! grep -F fatal filter-output\n '\n \n test_expect_success 'filter-branch handles ref deletion' '\ndiff --git a/t/t9133-git-svn-nested-git-repo.sh b/t/t9133-git-svn-nested-git-repo.sh\nindex f894860867..d8d536269c 100755\n--- a/t/t9133-git-svn-nested-git-repo.sh\n+++ b/t/t9133-git-svn-nested-git-repo.sh\n@@ -35,7 +35,7 @@ test_expect_success 'SVN-side change outside of .git' '\n \t\techo b >> a &&\n \t\tsvn_cmd commit -m \"SVN-side change outside of .git\" &&\n \t\tsvn_cmd up &&\n-\t\tsvn_cmd log -v | fgrep \"SVN-side change outside of .git\"\n+\t\tsvn_cmd log -v | grep -F \"SVN-side change outside of .git\"\n \t)\n '\n \n@@ -59,7 +59,7 @@ test_expect_success 'SVN-side change inside of .git' '\n \t\tsvn_cmd add --force .git &&\n \t\tsvn_cmd commit -m \"SVN-side change inside of .git\" &&\n \t\tsvn_cmd up &&\n-\t\tsvn_cmd log -v | fgrep \"SVN-side change inside of .git\"\n+\t\tsvn_cmd log -v | grep -F \"SVN-side change inside of .git\"\n \t)\n '\n \n@@ -82,7 +82,7 @@ test_expect_success 'SVN-side change in and out of .git' '\n \t\tgit commit -m \"add a inside an SVN repo\" &&\n \t\tsvn_cmd commit -m \"SVN-side change in and out of .git\" &&\n \t\tsvn_cmd up &&\n-\t\tsvn_cmd log -v | fgrep \"SVN-side change in and out of .git\"\n+\t\tsvn_cmd log -v | grep -F \"SVN-side change in and out of .git\"\n \t)\n '\n \ndiff --git a/t/t9134-git-svn-ignore-paths.sh b/t/t9134-git-svn-ignore-paths.sh\nindex 4a77eb9f60..21b5d285d5 100755\n--- a/t/t9134-git-svn-ignore-paths.sh\n+++ b/t/t9134-git-svn-ignore-paths.sh\n@@ -43,7 +43,7 @@ test_expect_success 'init+fetch an SVN repository with ignored www directory' '\n test_expect_success 'verify ignore-paths config saved by clone' '\n \t(\n \t    cd g &&\n-\t    git config --get svn-remote.svn.ignore-paths | fgrep \"www\"\n+\t    git config --get svn-remote.svn.ignore-paths | grep -F \"www\"\n \t)\n '\n \n@@ -53,7 +53,7 @@ test_expect_success 'SVN-side change outside of www' '\n \t\techo b >> qqq/test_qqq.txt &&\n \t\tsvn_cmd commit -m \"SVN-side change outside of www\" &&\n \t\tsvn_cmd up &&\n-\t\tsvn_cmd log -v | fgrep \"SVN-side change outside of www\"\n+\t\tsvn_cmd log -v | grep -F \"SVN-side change outside of www\"\n \t)\n '\n \n@@ -85,7 +85,7 @@ test_expect_success 'SVN-side change inside of ignored www' '\n \t\techo zaq >> www/test_www.txt &&\n \t\tsvn_cmd commit -m \"SVN-side change inside of www/test_www.txt\" &&\n \t\tsvn_cmd up &&\n-\t\tsvn_cmd log -v | fgrep \"SVN-side change inside of www/test_www.txt\"\n+\t\tsvn_cmd log -v | grep -F \"SVN-side change inside of www/test_www.txt\"\n \t)\n '\n \n@@ -118,7 +118,7 @@ test_expect_success 'SVN-side change in and out of ignored www' '\n \t\techo ygg >> qqq/test_qqq.txt &&\n \t\tsvn_cmd commit -m \"SVN-side change in and out of ignored www\" &&\n \t\tsvn_cmd up &&\n-\t\tsvn_cmd log -v | fgrep \"SVN-side change in and out of ignored www\"\n+\t\tsvn_cmd log -v | grep -F \"SVN-side change in and out of ignored www\"\n \t)\n '\n \ndiff --git a/t/t9140-git-svn-reset.sh b/t/t9140-git-svn-reset.sh\nindex e855904629..b3c9425d55 100755\n--- a/t/t9140-git-svn-reset.sh\n+++ b/t/t9140-git-svn-reset.sh\n@@ -43,7 +43,7 @@ test_expect_success 'fetch fails on modified hidden file' '\n \t  git svn find-rev refs/remotes/git-svn > ../expect &&\n \t  test_must_fail git svn fetch 2> ../errors &&\n \t  git svn find-rev refs/remotes/git-svn > ../expect2 ) &&\n-\tfgrep \"not found in commit\" errors &&\n+\tgrep -F \"not found in commit\" errors &&\n \ttest_cmp expect expect2\n '\n \n@@ -59,7 +59,7 @@ test_expect_success 'refetch succeeds not ignoring any files' '\n \t( cd g &&\n \t  git svn fetch &&\n \t  git svn rebase &&\n-\t  fgrep \"mod hidden\" hid/hid.txt\n+\t  grep -F \"mod hidden\" hid/hid.txt\n \t)\n '\n \ndiff --git a/t/t9147-git-svn-include-paths.sh b/t/t9147-git-svn-include-paths.sh\nindex 257fc8f2f8..e53bfc02f6 100755\n--- a/t/t9147-git-svn-include-paths.sh\n+++ b/t/t9147-git-svn-include-paths.sh\n@@ -45,7 +45,7 @@ test_expect_success 'init+fetch an SVN repository with included qqq directory' '\n test_expect_success 'verify include-paths config saved by clone' '\n \t(\n \t    cd g &&\n-\t    git config --get svn-remote.svn.include-paths | fgrep \"qqq\"\n+\t    git config --get svn-remote.svn.include-paths | grep -F \"qqq\"\n \t)\n '\n \n@@ -55,7 +55,7 @@ test_expect_success 'SVN-side change outside of www' '\n \t\techo b >> qqq/test_qqq.txt &&\n \t\tsvn_cmd commit -m \"SVN-side change outside of www\" &&\n \t\tsvn_cmd up &&\n-\t\tsvn_cmd log -v | fgrep \"SVN-side change outside of www\"\n+\t\tsvn_cmd log -v | grep -F \"SVN-side change outside of www\"\n \t)\n '\n \n@@ -87,7 +87,7 @@ test_expect_success 'SVN-side change inside of ignored www' '\n \t\techo zaq >> www/test_www.txt &&\n \t\tsvn_cmd commit -m \"SVN-side change inside of www/test_www.txt\" &&\n \t\tsvn_cmd up &&\n-\t\tsvn_cmd log -v | fgrep \"SVN-side change inside of www/test_www.txt\"\n+\t\tsvn_cmd log -v | grep -F \"SVN-side change inside of www/test_www.txt\"\n \t)\n '\n \n@@ -120,7 +120,7 @@ test_expect_success 'SVN-side change in and out of included qqq' '\n \t\techo ygg >> qqq/test_qqq.txt &&\n \t\tsvn_cmd commit -m \"SVN-side change in and out of ignored www\" &&\n \t\tsvn_cmd up &&\n-\t\tsvn_cmd log -v | fgrep \"SVN-side change in and out of ignored www\"\n+\t\tsvn_cmd log -v | grep -F \"SVN-side change in and out of ignored www\"\n \t)\n '\n \n-- \n2.38.0.rc0\n\n"},{"id":"463316","messageId":"20220920164317.GA1704@szeder.dev","threadId":"58474","inReplyTo":"752b12ef1e27d3b69d6aa3734309895082be7886.1663688697.git.congdanhqx@gmail.com","subject":"Re: [PATCH 2/4] t: remove \\{m,n\\} from BRE grep usage","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2022-09-20T16:43:17Z","receivedAt":"2022-09-20T16:43:25Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Tue, Sep 20, 2022 at 10:49:14PM +0700, Đoàn Trần Công Danh wrote:\n> \\{m,n\\} is a GNU extension to BRE, and it's forbidden by our\n> CodingGuidelines.\n> \n> Change to fixed strings or ERE.\n> \n> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n> ---\n>  t/t3200-branch.sh             | 6 ++++--\n>  t/t3305-notes-fanout.sh       | 2 +-\n>  t/t3404-rebase-interactive.sh | 6 +++---\n>  t/t5550-http-fetch-dumb.sh    | 2 +-\n>  t/t5702-protocol-v2.sh        | 2 +-\n>  5 files changed, 10 insertions(+), 8 deletions(-)\n> \n> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\n> index 9723c2827c..f05ac1fe0b 100755\n> --- a/t/t3200-branch.sh\n> +++ b/t/t3200-branch.sh\n> @@ -201,8 +201,10 @@ test_expect_success 'git branch -M baz bam should succeed when baz is checked ou\n>  \n>  test_expect_success 'git branch -M baz bam should add entries to .git/logs/HEAD' '\n>  \tmsg=\"Branch: renamed refs/heads/baz to refs/heads/bam\" &&\n> -\tgrep \" 0\\{40\\}.*$msg$\" .git/logs/HEAD &&\n> -\tgrep \"^0\\{40\\}.*$msg$\" .git/logs/HEAD\n> +\tzero=\"00000000\" &&\n> +\tzero=\"$zero$zero$zero$zero$zero\" &&\n> +\tgrep \" $zero.*$msg$\" .git/logs/HEAD &&\n> +\tgrep \"^$zero.*$msg$\" .git/logs/HEAD\n\nI think these could use $ZERO_OID instead.\n\n"},{"id":"463317","messageId":"10c27e60-792a-ae19-8af5-bdf9c134f145@gmail.com","threadId":"58474","inReplyTo":"752b12ef1e27d3b69d6aa3734309895082be7886.1663688697.git.congdanhqx@gmail.com","subject":"Re: [PATCH 2/4] t: remove \\{m,n\\} from BRE grep usage","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2022-09-20T17:42:54Z","receivedAt":"2022-09-20T17:43:00Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Đoàn\n\nOn 20/09/2022 16:49, Đoàn Trần Công Danh wrote:\n> \\{m,n\\} is a GNU extension to BRE, and it's forbidden by our\n> CodingGuidelines.\n\n\\{m,n\\} is valid in a posix BRE[1]. If we're already using it without \nanyone complaining I think it would be better to update CodingGuidlines \nto allow it.\n\nBest Wishes\n\nPhillip\n\n[1] \nhttps://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html\n\nSection 9.3.6 says\n...\n5. When a BRE matching a single character, a subexpression, or a \nback-reference is followed by an interval expression of the format \n\"\\{m\\}\", \"\\{m,\\}\", or \"\\{m,n\\}\", together with that interval expression \nit shall match what repeated consecutive occurrences of the BRE would \nmatch. The values of m and n are decimal integers in the range 0 <= m<= \nn<= {RE_DUP_MAX}, where m specifies the exact or minimum number of \noccurrences and n specifies the maximum number of occurrences. The \nexpression \"\\{m\\}\" shall match exactly m occurrences of the preceding \nBRE, \"\\{m,\\}\" shall match at least m occurrences, and \"\\{m,n\\}\" shall \nmatch any number of occurrences between m and n, inclusive.\n\nFor example, in the string \"abababccccccd\" the BRE \"c\\{3\\}\" is matched \nby characters seven to nine, the BRE \"\\(ab\\)\\{4,\\}\" is not matched at \nall, and the BRE \"c\\{1,3\\}d\" is matched by characters ten to thirteen.\n\n> Change to fixed strings or ERE.\n> \n> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n> ---\n>   t/t3200-branch.sh             | 6 ++++--\n>   t/t3305-notes-fanout.sh       | 2 +-\n>   t/t3404-rebase-interactive.sh | 6 +++---\n>   t/t5550-http-fetch-dumb.sh    | 2 +-\n>   t/t5702-protocol-v2.sh        | 2 +-\n>   5 files changed, 10 insertions(+), 8 deletions(-)\n> \n> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\n> index 9723c2827c..f05ac1fe0b 100755\n> --- a/t/t3200-branch.sh\n> +++ b/t/t3200-branch.sh\n> @@ -201,8 +201,10 @@ test_expect_success 'git branch -M baz bam should succeed when baz is checked ou\n>   \n>   test_expect_success 'git branch -M baz bam should add entries to .git/logs/HEAD' '\n>   \tmsg=\"Branch: renamed refs/heads/baz to refs/heads/bam\" &&\n> -\tgrep \" 0\\{40\\}.*$msg$\" .git/logs/HEAD &&\n> -\tgrep \"^0\\{40\\}.*$msg$\" .git/logs/HEAD\n> +\tzero=\"00000000\" &&\n> +\tzero=\"$zero$zero$zero$zero$zero\" &&\n> +\tgrep \" $zero.*$msg$\" .git/logs/HEAD &&\n> +\tgrep \"^$zero.*$msg$\" .git/logs/HEAD\n>   '\n>   \n>   test_expect_success 'git branch -M should leave orphaned HEAD alone' '\n> diff --git a/t/t3305-notes-fanout.sh b/t/t3305-notes-fanout.sh\n> index 22ffe5bcb9..aa3bb2e308 100755\n> --- a/t/t3305-notes-fanout.sh\n> +++ b/t/t3305-notes-fanout.sh\n> @@ -9,7 +9,7 @@ path_has_fanout() {\n>   \tpath=$1 &&\n>   \tfanout=$2 &&\n>   \tafter_last_slash=$(($(test_oid hexsz) - $fanout * 2)) &&\n> -\techo $path | grep -q \"^\\([0-9a-f]\\{2\\}/\\)\\{$fanout\\}[0-9a-f]\\{$after_last_slash\\}$\"\n> +\techo $path | grep -q -E \"^([0-9a-f][0-9a-f]/){$fanout}[0-9a-f]{$after_last_slash}$\"\n>   }\n>   \n>   touched_one_note_with_fanout() {\n> diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\n> index 688b01e3eb..4f5abb5ad2 100755\n> --- a/t/t3404-rebase-interactive.sh\n> +++ b/t/t3404-rebase-interactive.sh\n> @@ -1244,9 +1244,9 @@ test_expect_success 'short commit ID collide' '\n>   \t\ttest $colliding_id = \"$(git rev-parse HEAD | cut -c 1-4)\" &&\n>   \t\tgrep \"^pick $colliding_id \" \\\n>   \t\t\t.git/rebase-merge/git-rebase-todo.tmp &&\n> -\t\tgrep \"^pick [0-9a-f]\\{$hexsz\\}\" \\\n> +\t\tgrep -E \"^pick [0-9a-f]{$hexsz}\" \\\n>   \t\t\t.git/rebase-merge/git-rebase-todo &&\n> -\t\tgrep \"^pick [0-9a-f]\\{$hexsz\\}\" \\\n> +\t\tgrep -E \"^pick [0-9a-f]{$hexsz}\" \\\n>   \t\t\t.git/rebase-merge/git-rebase-todo.backup &&\n>   \t\tgit rebase --continue\n>   \t) &&\n> @@ -1261,7 +1261,7 @@ test_expect_success 'respect core.abbrev' '\n>   \t\tset_cat_todo_editor &&\n>   \t\ttest_must_fail git rebase -i HEAD~4 >todo-list\n>   \t) &&\n> -\ttest 4 = $(grep -c \"pick [0-9a-f]\\{12,\\}\" todo-list)\n> +\ttest 4 = $(grep -c -E \"pick [0-9a-f]{12,}\" todo-list)\n>   '\n>   \n>   test_expect_success 'todo count' '\n> diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh\n> index d7cf85ffea..8f182a3cbf 100755\n> --- a/t/t5550-http-fetch-dumb.sh\n> +++ b/t/t5550-http-fetch-dumb.sh\n> @@ -234,7 +234,7 @@ test_expect_success 'http-fetch --packfile' '\n>   \t\t--index-pack-arg=--keep \\\n>   \t\t\"$HTTPD_URL\"/dumb/repo_pack.git/$p >out &&\n>   \n> -\tgrep \"^keep.[0-9a-f]\\{16,\\}$\" out &&\n> +\tgrep -E \"^keep.[0-9a-f]{16,}$\" out &&\n>   \tcut -c6- out >packhash &&\n>   \n>   \t# Ensure that the expected files are generated\n> diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh\n> index 5d42a355a8..b33cd4afca 100755\n> --- a/t/t5702-protocol-v2.sh\n> +++ b/t/t5702-protocol-v2.sh\n> @@ -1001,7 +1001,7 @@ test_expect_success 'part of packfile response provided as URI' '\n>   \tdo\n>   \t\tgit verify-pack --object-format=$(test_oid algo) --verbose $idx >out &&\n>   \t\t{\n> -\t\t\tgrep \"^[0-9a-f]\\{16,\\} \" out || :\n> +\t\t\tgrep -E \"^[0-9a-f]{16,} \" out || :\n>   \t\t} >out.objectlist &&\n>   \t\tif test_line_count = 1 out.objectlist\n>   \t\tthen\n\n"},{"id":"463318","messageId":"xmqqa66u6iid.fsf@gitster.g","threadId":"58474","inReplyTo":"cover.1663688697.git.congdanhqx@gmail.com","subject":"Re: [PATCH 0/4] allow grep -E, and remove egrep","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-09-20T17:52:10Z","receivedAt":"2022-09-20T17:52:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:\n\n> Despite our CodingGuidelines dictates that grep -E and or grep \\{m,n\\}\n> are forbidden. Our code bases uses them all over place.\n\nThat makes it sounds like rules dictating and coders resisting, but\nthat is not what is happening.\n\nPortability guidelines need updating as tools on different platforms\nchange over time.  An effort like this series is very much\nappreciated from time to time.\n"},{"id":"463319","messageId":"xmqq35cm6ii3.fsf@gitster.g","threadId":"58474","inReplyTo":"752b12ef1e27d3b69d6aa3734309895082be7886.1663688697.git.congdanhqx@gmail.com","subject":"Re: [PATCH 2/4] t: remove \\{m,n\\} from BRE grep usage","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-09-20T17:52:20Z","receivedAt":"2022-09-20T17:52:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:\n\n> \\{m,n\\} is a GNU extension to BRE, and it's forbidden by our\n> CodingGuidelines.\n\nIs it?\n\nhttps://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_06\n\nsays otherwise.  There may be some other GNU extensions to BRE that\nallows you to write ERE elements with different syntax, but I doubt\nthis is one of them.  Perhaps you are thinking about \"A\\|B\"\nalternation?  In ERE \"A|B\" is alternation, and GNU BRE allows \"A\\|B\"\nbut that is outside POSIX, IIUC.  \"A\\+\" (1 or more of A) and \"A\\?\"\n(0 or 1 of A) are the same way.\n\nWe do say we don't use \"\\{m,n\\}\" in the guidelines, which was\nwritten more than 10 years ago that codifies the habit acquired\nwhile having to deal with regexp implementations of various UNIX\nvariants like early SystemV and BSD4 from more than 20 years ago.\n\nIf we are using the syntax in many of our tests that everybody runs,\nthat can be taken as a sign that those platforms who had problems\nwith the syntax have died out, or at least to them Git does not\nmatter.\n\nSo my prefererence is to\n\n - Allow \\{m,n\\} when it makes sense and codify it in the guidelines\n\n - Rewriting tests is fine if it makes the result easier to read,\n   but it shouldn't be done for the sole purpose of getting rid of\n   the \\{m,n\\} syntax.\n\n - As there are folks without GNU, until these GNU extensions for |,\n   +, and ? are adopted widely, keep forbidding their use in BRE.\n\n>  test_expect_success 'git branch -M baz bam should add entries to .git/logs/HEAD' '\n>  \tmsg=\"Branch: renamed refs/heads/baz to refs/heads/bam\" &&\n> -\tgrep \" 0\\{40\\}.*$msg$\" .git/logs/HEAD &&\n> -\tgrep \"^0\\{40\\}.*$msg$\" .git/logs/HEAD\n> +\tzero=\"00000000\" &&\n> +\tzero=\"$zero$zero$zero$zero$zero\" &&\n> +\tgrep \" $zero.*$msg$\" .git/logs/HEAD &&\n> +\tgrep \"^$zero.*$msg$\" .git/logs/HEAD\n>  '\n\nThis is not good\n\n>  test_expect_success 'git branch -M should leave orphaned HEAD alone' '\n> diff --git a/t/t3305-notes-fanout.sh b/t/t3305-notes-fanout.sh\n> index 22ffe5bcb9..aa3bb2e308 100755\n> --- a/t/t3305-notes-fanout.sh\n> +++ b/t/t3305-notes-fanout.sh\n> @@ -9,7 +9,7 @@ path_has_fanout() {\n>  \tpath=$1 &&\n>  \tfanout=$2 &&\n>  \tafter_last_slash=$(($(test_oid hexsz) - $fanout * 2)) &&\n> -\techo $path | grep -q \"^\\([0-9a-f]\\{2\\}/\\)\\{$fanout\\}[0-9a-f]\\{$after_last_slash\\}$\"\n> +\techo $path | grep -q -E \"^([0-9a-f][0-9a-f]/){$fanout}[0-9a-f]{$after_last_slash}$\"\n\nThe use of -E makes it more readable and is good.  The innermost \"a\npair of hexdigits\" that would repeat $fanout times may be easier to\nread if you keep the {2}, though.\n\n"}]}