{"thread":{"id":"24157","subject":"[PATCH 2/3] t/t7811-grep-open.sh: ensure fake \"less\" is made executable","startedAt":"2010-06-21T17:37:13Z","lastAt":"2010-06-21T18:11:00Z","messageCount":4,"participants":["Brandon Casey","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"143985","messageId":"__CrpvAIIX9lgHHkBLHB9fuuN7Rspzl7LFSDSwXwVCT6rYs_YOUHNMf7JZQbKaPHRl6AjsJ9dx8@cipher.nrlssc.navy.mil","threadId":"24157","inReplyTo":null,"subject":"[PATCH 1/3] t/lib-pager.sh: remove unnecessary '^' from 'expr' regular expression","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2010-06-21T17:37:13Z","receivedAt":"2010-06-21T17:37:13Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nRegular expressions matched by 'expr' have an implicit '^' at the beginning\nof them and so are anchored to the beginning of the string.  Using the '^'\ncharacter to mean \"match at the beginning\", is redundant and could produce\nthe wrong result if 'expr' implementations interpret the '^' as a literal\n'^'.  Additionally, GNU expr 5.97 complains like this:\n\n   expr: warning: unportable BRE: `^[a-z][a-z]*$': using `^' as the first character of the basic regular expression is not portable; it is being ignored\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n t/lib-pager.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/lib-pager.sh b/t/lib-pager.sh\nindex f8c6025..ba03eab 100644\n--- a/t/lib-pager.sh\n+++ b/t/lib-pager.sh\n@@ -9,7 +9,7 @@ test_expect_success 'determine default pager' '\n \ttest -n \"$less\"\n '\n \n-if expr \"$less\" : '^[a-z][a-z]*$' >/dev/null\n+if expr \"$less\" : '[a-z][a-z]*$' >/dev/null\n then\n \ttest_set_prereq SIMPLEPAGER\n fi\n-- \n1.6.6.2\n"},{"id":"143984","messageId":"__CrpvAIIX9lgHHkBLHB9a3UByh6vEB5nG8C7-bzzaY-zhXjKlkZfsB4GNmQRsIYGu10jf-0sjU@cipher.nrlssc.navy.mil","threadId":"24157","inReplyTo":"__CrpvAIIX9lgHHkBLHB9fuuN7Rspzl7LFSDSwXwVCT6rYs_YOUHNMf7JZQbKaPHRl6AjsJ9dx8@cipher.nrlssc.navy.mil","subject":"[PATCH 2/3] t/t7811-grep-open.sh: ensure fake \"less\" is made executable","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2010-06-21T17:37:14Z","receivedAt":"2010-06-21T17:37:14Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nThe fake \"less\" script was not being made executable.  This can cause the\ntests that follow to fail.  This failure is not apparent on platforms which\nhave DEFAULT_PAGER set to the string \"less\", since lib-pager.sh will have\nset the $less variable to \"less\" and the SIMPLEPAGER prerequisite will have\nbeen set, and so the \"less\" script will have already been created properly\nand made executable in test 2 'git grep -O'.  On platforms which set\nDEFAULT_PAGER to something like \"more\", no such script will have been\npreviously created, and tests 7 and 8 will fail.\n\nSo, add a call to chmod to make the fake \"less\" script executable.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n t/t7811-grep-open.sh |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t7811-grep-open.sh b/t/t7811-grep-open.sh\nindex 8db4fc8..2e5c701 100755\n--- a/t/t7811-grep-open.sh\n+++ b/t/t7811-grep-open.sh\n@@ -84,10 +84,11 @@ test_expect_success 'git grep -O --no-index' '\n '\n \n test_expect_success 'setup: fake \"less\"' '\n-\tcat >less <<-\\EOF\n+\tcat >less <<-\\EOF &&\n \t#!/bin/sh\n \tprintf \"%s\\n\" \"$@\" >actual\n \tEOF\n+\tchmod +x less\n '\n \n test_expect_success 'git grep -O jumps to line in less' '\n-- \n1.6.6.2\n"},{"id":"143986","messageId":"__CrpvAIIX9lgHHkBLHB9XDHAxBXxWdeEjxUzFD8IDsCriIMGC3nkCjyvNdGPppHV_Yf_CyEmg8@cipher.nrlssc.navy.mil","threadId":"24157","inReplyTo":"__CrpvAIIX9lgHHkBLHB9fuuN7Rspzl7LFSDSwXwVCT6rYs_YOUHNMf7JZQbKaPHRl6AjsJ9dx8@cipher.nrlssc.navy.mil","subject":"[PATCH 3/3] t/t7811-grep-open.sh: remove broken/redundant creation of fake \"less\" script","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2010-06-21T17:37:15Z","receivedAt":"2010-06-21T17:37:15Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nThe fake \"less\" script was already created in a previous test titled\n'setup: fake \"less\"', so it is redundant.  Additionally, it is broken since\nthe redirection of 'cat' is to a file named 'less', but the chmod operates\non the file named by the $less variable which may not contain the value\n'less'.\n\nSo, just remove this code, and rely on the creation of the fake \"less\"\nscript performed earlier within the test script.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n t/t7811-grep-open.sh |    5 -----\n 1 files changed, 0 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t7811-grep-open.sh b/t/t7811-grep-open.sh\nindex 2e5c701..c110441 100755\n--- a/t/t7811-grep-open.sh\n+++ b/t/t7811-grep-open.sh\n@@ -109,11 +109,6 @@ test_expect_success 'git grep -O jumps to line in less' '\n \n test_expect_success 'modified file' '\n \trm -f actual &&\n-\tcat >less <<-\\EOF &&\n-\t#!/bin/sh\n-\tprintf \"%s\\n\" \"$@\" >actual\n-\tEOF\n-\tchmod +x $less &&\n \tcat >expect <<-\\EOF &&\n \t+/*enum grep_pat_token\n \tgrep.h\n-- \n1.6.6.2\n"},{"id":"143987","messageId":"7vd3vki7d7.fsf@alter.siamese.dyndns.org","threadId":"24157","inReplyTo":"__CrpvAIIX9lgHHkBLHB9fuuN7Rspzl7LFSDSwXwVCT6rYs_YOUHNMf7JZQbKaPHRl6AjsJ9dx8@cipher.nrlssc.navy.mil","subject":"Re: [PATCH 1/3] t/lib-pager.sh: remove unnecessary '^' from 'expr' regular expression","fromName":"Junio C Hamano","fromEmail":"junio@pobox.com","sentAt":"2010-06-21T18:11:00Z","receivedAt":"2010-06-21T18:11:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Casey <casey@nrlssc.navy.mil> writes:\n\n> From: Brandon Casey <drafnel@gmail.com>\n>\n> Regular expressions matched by 'expr' have an implicit '^' at the beginning\n> of them and so are anchored to the beginning of the string.\n\nOh, of course; I should have caught this earlier.\n\n$ git grep -n -e 'expr .*: .*['\\''\"]^'\nt/lib-pager.sh:12:if expr \"$less\" : '^[a-z][a-z]*$' >/dev/null\nt/t7005-editor.sh:16:if ! expr \"$vi\" : '^[a-z]*$' >/dev/null\nt/t7006-pager.sh:113:   ! expr \"$firstline\" : \"^[a-zA-Z]\" >/dev/null\n\nI'll fix the other two; thanks.\n"}]}