{"thread":{"id":"1148","subject":"[PATCH 2/2] Write sed script directly into temp file, rather than a variable","startedAt":"2005-07-07T00:50:07Z","lastAt":"2005-07-07T00:50:07Z","messageCount":1,"participants":["Jon Seymour"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"5741","messageId":"20050707005007.9224.qmail@blackcubes.dyndns.org","threadId":"1148","inReplyTo":null,"subject":"[PATCH 2/2] Write sed script directly into temp file, rather than a variable","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2005-07-07T00:50:07Z","receivedAt":"2005-07-07T00:50:07Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"\nWhen sed uses \\n rather than ; as a separator (for BSD sed(1) compat),\nit is cleaner to use a file directly, rather than an environment\nvariable containing \\n characters.\n\nThis change changes t/t6000 write to sed.script directly and changes\nthe other tests to remove knowledge of sed.script.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n\n t/t6000-lib.sh                  |   12 +++++++-----\n t/t6001-rev-list-merge-order.sh |    9 ---------\n t/t6002-rev-list-bisect.sh      |   10 ----------\n t/t6003-rev-list-topo-order.sh  |    9 ---------\n 4 files changed, 7 insertions(+), 33 deletions(-)\n\n8e14d7142551c4eca6718894943e33a2a0a2a14f\ndiff --git a/t/t6000-lib.sh b/t/t6000-lib.sh\n--- a/t/t6000-lib.sh\n+++ b/t/t6000-lib.sh\n@@ -1,6 +1,6 @@\n [ -d .git/refs/tags ] || mkdir -p .git/refs/tags\n \n-sed_script=\"\";\n+:> sed.script\n \n # Answer the sha1 has associated with the tag. The tag must exist in .git or .git/refs/tags\n tag()\n@@ -21,7 +21,7 @@ unique_commit()\n }\n \n # Save the output of a command into the tag specified. Prepend\n-# a substitution script for the tag onto the front of $sed_script\n+# a substitution script for the tag onto the front of sed.script\n save_tag()\n {\n \t_tag=$1\t\n@@ -29,14 +29,16 @@ save_tag()\n \tshift 1\n     \t\"$@\" >.git/refs/tags/$_tag\n \n-       sed_script=\"s/$(tag $_tag)/$_tag/g\n-$sed_script\"\n+        echo \"s/$(tag $_tag)/$_tag/g\" > sed.script.tmp\n+\tcat sed.script >> sed.script.tmp\n+\trm sed.script\n+\tmv sed.script.tmp sed.script\n }\n \n # Replace unhelpful sha1 hashses with their symbolic equivalents \n entag()\n {\n-\tsed \"$sed_script\"\n+\tsed -f sed.script\n }\n \n # Execute a command after first saving, then setting the GIT_AUTHOR_EMAIL\ndiff --git a/t/t6001-rev-list-merge-order.sh b/t/t6001-rev-list-merge-order.sh\n--- a/t/t6001-rev-list-merge-order.sh\n+++ b/t/t6001-rev-list-merge-order.sh\n@@ -103,15 +103,6 @@ save_tag g4 unique_commit g6 tree -p g3 \n \n tag l5 > .git/HEAD\n \n-#\n-# cd to t/trash and use \n-#\n-#    git-rev-list ... 2>&1 | sed \"$(cat sed.script)\" \n-#\n-# if you ever want to manually debug the operation of git-rev-list\n-#\n-echo $sed_script > sed.script\n-\n test_expect_success 'rev-list has correct number of entries' 'git-rev-list HEAD | wc -l | tr -s \" \"' <<EOF\n 19\n EOF\ndiff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh\n--- a/t/t6002-rev-list-bisect.sh\n+++ b/t/t6002-rev-list-bisect.sh\n@@ -113,16 +113,6 @@ on_committer_date \"1971-08-16 00:00:04\" \n on_committer_date \"1971-08-16 00:00:05\" save_tag u5 unique_commit u5 tree -p u0\n on_committer_date \"1971-08-16 00:00:06\" save_tag V unique_commit V tree -p u1 -p u2 -p u3 -p u4 -p u5\n \n-\n-#\n-# cd to t/trash and use \n-#\n-#    git-rev-list ... 2>&1 | sed \"$(cat sed.script)\" \n-#\n-# if you ever want to manually debug the operation of git-rev-list\n-#\n-echo $sed_script > sed.script\n-\n test_sequence()\n {\n \t_bisect_option=$1\t\ndiff --git a/t/t6003-rev-list-topo-order.sh b/t/t6003-rev-list-topo-order.sh\n--- a/t/t6003-rev-list-topo-order.sh\n+++ b/t/t6003-rev-list-topo-order.sh\n@@ -79,15 +79,6 @@ save_tag g4 unique_commit g6 tree -p g3 \n \n tag l5 > .git/HEAD\n \n-#\n-# cd to t/trash and use \n-#\n-#    git-rev-list ... 2>&1 | sed \"$(cat sed.script)\" \n-#\n-# if you ever want to manually debug the operation of git-rev-list\n-#\n-echo \"$sed_script\" | tr ' ' \\\\012 > sed.script\n-\n test_expect_success 'rev-list has correct number of entries' 'git-rev-list HEAD | wc -l | tr -s \" \"' <<EOF\n 19\n EOF\n------------\n"}]}