{"thread":{"id":"32505","subject":"[PATCH V2] t9810: Do not use sed -i","startedAt":"2013-01-01T23:20:19Z","lastAt":"2013-01-03T03:08:11Z","messageCount":4,"participants":["Torsten Bögershausen","Pete Wyckoff","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"205810","messageId":"201301020020.38535.tboegi@web.de","threadId":"32505","inReplyTo":null,"subject":"[PATCH V2] t9810: Do not use sed -i","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2013-01-01T23:20:19Z","receivedAt":"2013-01-01T23:20:19Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"sed -i is not portable on all systems.\nUse sed with different input and output files.\nUtilize a tmp file whenever needed\n\nAdded missing && at 2 places\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\nChanges since v1:\nUse \"sed <infile >outfile\"\nAdded missing && at 2 places (thanks for catching)\n t/t9810-git-p4-rcs.sh | 24 ++++++++++++++----------\n 1 file changed, 14 insertions(+), 10 deletions(-)\n\ndiff --git a/t/t9810-git-p4-rcs.sh b/t/t9810-git-p4-rcs.sh\nindex 0c2fc3e..01a9921 100755\n--- a/t/t9810-git-p4-rcs.sh\n+++ b/t/t9810-git-p4-rcs.sh\n@@ -26,10 +26,8 @@ test_expect_success 'init depot' '\n \t\tline7\n \t\tline8\n \t\tEOF\n-\t\tcp filek fileko &&\n-\t\tsed -i \"s/Revision/Revision: do not scrub me/\" fileko\n-\t\tcp fileko file_text &&\n-\t\tsed -i \"s/Id/Id: do not scrub me/\" file_text\n+\t\tsed \"s/Revision/Revision: do not scrub me/\" <filek >fileko &&\n+\t\tsed \"s/Id/Id: do not scrub me/\" <fileko >file_text &&\n \t\tp4 add -t text+k filek &&\n \t\tp4 submit -d \"filek\" &&\n \t\tp4 add -t text+ko fileko &&\n@@ -88,7 +86,8 @@ test_expect_success 'edit far away from RCS lines' '\n \t(\n \t\tcd \"$git\" &&\n \t\tgit config git-p4.skipSubmitEdit true &&\n-\t\tsed -i \"s/^line7/line7 edit/\" filek &&\n+\t\tsed \"s/^line7/line7 edit/\" <filek >filek.tmp &&\n+\t\tmv -f filek.tmp filek &&\n \t\tgit commit -m \"filek line7 edit\" filek &&\n \t\tgit p4 submit &&\n \t\tscrub_k_check filek\n@@ -105,7 +104,8 @@ test_expect_success 'edit near RCS lines' '\n \t\tcd \"$git\" &&\n \t\tgit config git-p4.skipSubmitEdit true &&\n \t\tgit config git-p4.attemptRCSCleanup true &&\n-\t\tsed -i \"s/^line4/line4 edit/\" filek &&\n+\t\tsed \"s/^line4/line4 edit/\" <filek >filek.tmp &&\n+\t\tmv -f filek.tmp filek &&\n \t\tgit commit -m \"filek line4 edit\" filek &&\n \t\tgit p4 submit &&\n \t\tscrub_k_check filek\n@@ -122,7 +122,8 @@ test_expect_success 'edit keyword lines' '\n \t\tcd \"$git\" &&\n \t\tgit config git-p4.skipSubmitEdit true &&\n \t\tgit config git-p4.attemptRCSCleanup true &&\n-\t\tsed -i \"/Revision/d\" filek &&\n+\t\tsed \"/Revision/d\" <filek >filek.tmp &&\n+\t\tmv -f filek.tmp filek &&\n \t\tgit commit -m \"filek remove Revision line\" filek &&\n \t\tgit p4 submit &&\n \t\tscrub_k_check filek\n@@ -139,7 +140,8 @@ test_expect_success 'scrub ko files differently' '\n \t\tcd \"$git\" &&\n \t\tgit config git-p4.skipSubmitEdit true &&\n \t\tgit config git-p4.attemptRCSCleanup true &&\n-\t\tsed -i \"s/^line4/line4 edit/\" fileko &&\n+\t\tsed <fileko \"s/^line4/line4 edit/\" >fileko.tmp &&\n+\t\tmv -f fileko.tmp fileko &&\n \t\tgit commit -m \"fileko line4 edit\" fileko &&\n \t\tgit p4 submit &&\n \t\tscrub_ko_check fileko &&\n@@ -189,12 +191,14 @@ test_expect_success 'do not scrub plain text' '\n \t\tcd \"$git\" &&\n \t\tgit config git-p4.skipSubmitEdit true &&\n \t\tgit config git-p4.attemptRCSCleanup true &&\n-\t\tsed -i \"s/^line4/line4 edit/\" file_text &&\n+\t\tsed \"s/^line4/line4 edit/\" <file_text >file_text.tmp &&\n+\t\tmv -f file_text.tmp file_text &&\n \t\tgit commit -m \"file_text line4 edit\" file_text &&\n \t\t(\n \t\t\tcd \"$cli\" &&\n \t\t\tp4 open file_text &&\n-\t\t\tsed -i \"s/^line5/line5 p4 edit/\" file_text &&\n+\t\t\tsed \"s/^line5/line5 p4 edit/\" <file_text >file_text.tmp &&\n+\t\t\tmv -f file_text.tmp file_text &&\n \t\t\tp4 submit -d \"file5 p4 edit\"\n \t\t) &&\n \t\techo s | test_expect_code 1 git p4 submit &&\n-- \n1.8.0.197.g5a90748\n"},{"id":"205892","messageId":"20130102224446.GA12363@padd.com","threadId":"32505","inReplyTo":"201301020020.38535.tboegi@web.de","subject":"Re: [PATCH V2] t9810: Do not use sed -i","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2013-01-02T22:44:46Z","receivedAt":"2013-01-02T22:44:46Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"tboegi@web.de wrote on Wed, 02 Jan 2013 00:20 +0100:\n> sed -i is not portable on all systems.\n> Use sed with different input and output files.\n> Utilize a tmp file whenever needed\n> \n> Added missing && at 2 places\n> \n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n\nOne more teensy fix is needed in this hunk, following Junio's\ncomment about redirections going at the end:\n\n> @@ -139,7 +140,8 @@ test_expect_success 'scrub ko files differently' '\n>  \t\tcd \"$git\" &&\n>  \t\tgit config git-p4.skipSubmitEdit true &&\n>  \t\tgit config git-p4.attemptRCSCleanup true &&\n> -\t\tsed -i \"s/^line4/line4 edit/\" fileko &&\n> +\t\tsed <fileko \"s/^line4/line4 edit/\" >fileko.tmp &&\n> +\t\tmv -f fileko.tmp fileko &&\n>  \t\tgit commit -m \"fileko line4 edit\" fileko &&\n>  \t\tgit p4 submit &&\n>  \t\tscrub_ko_check fileko &&\n\nI checked that the test still works with your changes.\n\nThanks for the cleanup!\n\nAcked-by: Pete Wyckoff <pw@padd.com>\n\n\t\t-- Pete\n"},{"id":"205893","messageId":"7vhamz18y3.fsf@alter.siamese.dyndns.org","threadId":"32505","inReplyTo":"20130102224446.GA12363@padd.com","subject":"Re: [PATCH V2] t9810: Do not use sed -i","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-01-02T23:06:28Z","receivedAt":"2013-01-02T23:06:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pete Wyckoff <pw@padd.com> writes:\n\n> tboegi@web.de wrote on Wed, 02 Jan 2013 00:20 +0100:\n>> sed -i is not portable on all systems.\n>> Use sed with different input and output files.\n>> Utilize a tmp file whenever needed\n>> \n>> Added missing && at 2 places\n>> \n>> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n>\n> One more teensy fix is needed in this hunk, following Junio's\n> comment about redirections going at the end:\n\nI've already pushed out the previous one on 'pu' after fixing it up\nlike this.\n\nThanks.  Anything I missed?\n\nDate: Tue, 1 Jan 2013 22:40:37 +0100\nSubject: [PATCH] t9810: Do not use sed -i\n\nsed -i is not portable on all systems.  Use sed with different input\nand output files.  Utilize a tmp file whenever needed.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t9810-git-p4-rcs.sh | 24 ++++++++++++++----------\n 1 file changed, 14 insertions(+), 10 deletions(-)\n\ndiff --git a/t/t9810-git-p4-rcs.sh b/t/t9810-git-p4-rcs.sh\nindex 0c2fc3e..34fbc90 100755\n--- a/t/t9810-git-p4-rcs.sh\n+++ b/t/t9810-git-p4-rcs.sh\n@@ -26,10 +26,8 @@ test_expect_success 'init depot' '\n \t\tline7\n \t\tline8\n \t\tEOF\n-\t\tcp filek fileko &&\n-\t\tsed -i \"s/Revision/Revision: do not scrub me/\" fileko\n-\t\tcp fileko file_text &&\n-\t\tsed -i \"s/Id/Id: do not scrub me/\" file_text\n+\t\tsed \"s/Revision/Revision: do not scrub me/\" <filek >fileko &&\n+\t\tsed \"s/Id/Id: do not scrub me/\" <fileko >file_text &&\n \t\tp4 add -t text+k filek &&\n \t\tp4 submit -d \"filek\" &&\n \t\tp4 add -t text+ko fileko &&\n@@ -88,7 +86,8 @@ test_expect_success 'edit far away from RCS lines' '\n \t(\n \t\tcd \"$git\" &&\n \t\tgit config git-p4.skipSubmitEdit true &&\n-\t\tsed -i \"s/^line7/line7 edit/\" filek &&\n+\t\tsed \"s/^line7/line7 edit/\" <filek >filek.tmp &&\n+\t\tmv -f filek.tmp filek &&\n \t\tgit commit -m \"filek line7 edit\" filek &&\n \t\tgit p4 submit &&\n \t\tscrub_k_check filek\n@@ -105,7 +104,8 @@ test_expect_success 'edit near RCS lines' '\n \t\tcd \"$git\" &&\n \t\tgit config git-p4.skipSubmitEdit true &&\n \t\tgit config git-p4.attemptRCSCleanup true &&\n-\t\tsed -i \"s/^line4/line4 edit/\" filek &&\n+\t\tsed \"s/^line4/line4 edit/\" <filek >filek.tmp &&\n+\t\tmv -f filek.tmp filek &&\n \t\tgit commit -m \"filek line4 edit\" filek &&\n \t\tgit p4 submit &&\n \t\tscrub_k_check filek\n@@ -122,7 +122,8 @@ test_expect_success 'edit keyword lines' '\n \t\tcd \"$git\" &&\n \t\tgit config git-p4.skipSubmitEdit true &&\n \t\tgit config git-p4.attemptRCSCleanup true &&\n-\t\tsed -i \"/Revision/d\" filek &&\n+\t\tsed \"/Revision/d\" <filek >filek.tmp &&\n+\t\tmv -f filek.tmp filek &&\n \t\tgit commit -m \"filek remove Revision line\" filek &&\n \t\tgit p4 submit &&\n \t\tscrub_k_check filek\n@@ -139,7 +140,8 @@ test_expect_success 'scrub ko files differently' '\n \t\tcd \"$git\" &&\n \t\tgit config git-p4.skipSubmitEdit true &&\n \t\tgit config git-p4.attemptRCSCleanup true &&\n-\t\tsed -i \"s/^line4/line4 edit/\" fileko &&\n+\t\tsed \"s/^line4/line4 edit/\" <fileko >fileko.tmp &&\n+\t\tmv -f fileko.tmp fileko &&\n \t\tgit commit -m \"fileko line4 edit\" fileko &&\n \t\tgit p4 submit &&\n \t\tscrub_ko_check fileko &&\n@@ -189,12 +191,14 @@ test_expect_success 'do not scrub plain text' '\n \t\tcd \"$git\" &&\n \t\tgit config git-p4.skipSubmitEdit true &&\n \t\tgit config git-p4.attemptRCSCleanup true &&\n-\t\tsed -i \"s/^line4/line4 edit/\" file_text &&\n+\t\tsed \"s/^line4/line4 edit/\" <file_text >file_text.tmp &&\n+\t\tmv -f file_text.tmp file_text &&\n \t\tgit commit -m \"file_text line4 edit\" file_text &&\n \t\t(\n \t\t\tcd \"$cli\" &&\n \t\t\tp4 open file_text &&\n-\t\t\tsed -i \"s/^line5/line5 p4 edit/\" file_text &&\n+\t\t\tsed \"s/^line5/line5 p4 edit/\" <file_text >file_text.tmp &&\n+\t\t\tmv -f file_text.tmp file_text &&\n \t\t\tp4 submit -d \"file5 p4 edit\"\n \t\t) &&\n \t\techo s | test_expect_code 1 git p4 submit &&\n-- \n1.8.1.203.gc241474\n"},{"id":"205909","messageId":"20130103030811.GA30979@padd.com","threadId":"32505","inReplyTo":"7vhamz18y3.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH V2] t9810: Do not use sed -i","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2013-01-03T03:08:11Z","receivedAt":"2013-01-03T03:08:11Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"gitster@pobox.com wrote on Wed, 02 Jan 2013 15:06 -0800:\n> Pete Wyckoff <pw@padd.com> writes:\n> \n> > tboegi@web.de wrote on Wed, 02 Jan 2013 00:20 +0100:\n> >> sed -i is not portable on all systems.\n> >> Use sed with different input and output files.\n> >> Utilize a tmp file whenever needed\n> >> \n> >> Added missing && at 2 places\n> >> \n> >> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> >\n> > One more teensy fix is needed in this hunk, following Junio's\n> > comment about redirections going at the end:\n> \n> I've already pushed out the previous one on 'pu' after fixing it up\n> like this.\n> \n> Thanks.  Anything I missed?\n\nI should have guessed that you would just silently fix it.\nThanks!\n\n\t\t-- Pete\n"}]}