{"thread":{"id":"36878","subject":"[PATCH v3] t9001: avoid not portable '\\n' with sed","startedAt":"2014-06-10T04:07:59Z","lastAt":"2014-06-10T15:38:17Z","messageCount":5,"participants":["Torsten Bögershausen","Eric Sunshine","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"243698","messageId":"5396849F.7060206@web.de","threadId":"36878","inReplyTo":null,"subject":"[PATCH v3] t9001: avoid not portable '\\n' with sed","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2014-06-10T04:07:59Z","receivedAt":"2014-06-10T04:07:59Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"t9001 used a '\\n' in a sed expression to split one line into two lines,\nbut the usage of '\\n' in the \"replacement string\" is not portable.\n\nThe '\\n' can be used to match a newline in the \"pattern space\",\nbut otherwise the meaning of '\\n' is unspecified in POSIX.\n\n- Gnu versions of sed will treat '\\n' as a newline character.\n- Other versions of sed (like /usr/bin/sed under Mac OS X)\n  simply ignore the '\\' before the 'n', treating '\\n' as 'n'.\n\nFor reference see:\npubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html\nhttp://www.gnu.org/software/sed/manual/sed.html\n\nAs the test already requires perl as a prerequisite, use perl instead of sed.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\nSending a V3 patch seems \"spammish\", but after re-reading all\nthe comments I think that the commit msg should point out the difference\nbetween POSIX sed and gnu sed somewhat better.\n\n t/t9001-send-email.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 64d9434..19a3ced 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -1342,7 +1342,7 @@ test_cover_addresses () {\n \tgit format-patch --cover-letter -2 -o outdir &&\n \tcover=`echo outdir/0000-*.patch` &&\n \tmv $cover cover-to-edit.patch &&\n-\tsed \"s/^From:/$header: extra@address.com\\nFrom:/\" cover-to-edit.patch >\"$cover\" &&\n+\tperl -pe \"s/^From:/$header: extra\\@address.com\\nFrom:/\" cover-to-edit.patch >\"$cover\" &&\n \tgit send-email \\\n \t  --force \\\n \t  --from=\"Example <nobody@example.com>\" \\\n-- \n2.0.0.553.ged01b91\n"},{"id":"243699","messageId":"CAPig+cTeqjj6pstzvRh2z6CW8ksW5tpz41+RzpO=Aj2gYr7DAg@mail.gmail.com","threadId":"36878","inReplyTo":"5396849F.7060206@web.de","subject":"Re: [PATCH v3] t9001: avoid not portable '\\n' with sed","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2014-06-10T05:03:16Z","receivedAt":"2014-06-10T05:03:16Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Jun 10, 2014 at 12:07 AM, Torsten Bögershausen <tboegi@web.de> wrote:\n> t9001 used a '\\n' in a sed expression to split one line into two lines,\n> but the usage of '\\n' in the \"replacement string\" is not portable.\n>\n> The '\\n' can be used to match a newline in the \"pattern space\",\n> but otherwise the meaning of '\\n' is unspecified in POSIX.\n>\n> - Gnu versions of sed will treat '\\n' as a newline character.\n> - Other versions of sed (like /usr/bin/sed under Mac OS X)\n>   simply ignore the '\\' before the 'n', treating '\\n' as 'n'.\n>\n> For reference see:\n> pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html\n> http://www.gnu.org/software/sed/manual/sed.html\n>\n> As the test already requires perl as a prerequisite, use perl instead of sed.\n\nRené Scharfe pointed out this useful resource [1] for writing portable\n'sed' when he fixed [2] a problem on NetBSD in a test I had written.\n\n[1]: http://sed.sourceforge.net/sedfaq4.html\n[2]: http://thread.gmane.org/gmane.comp.version-control.git/231654\n\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n> Sending a V3 patch seems \"spammish\", but after re-reading all\n> the comments I think that the commit msg should point out the difference\n> between POSIX sed and gnu sed somewhat better.\n>\n>  t/t9001-send-email.sh | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\n> index 64d9434..19a3ced 100755\n> --- a/t/t9001-send-email.sh\n> +++ b/t/t9001-send-email.sh\n> @@ -1342,7 +1342,7 @@ test_cover_addresses () {\n>         git format-patch --cover-letter -2 -o outdir &&\n>         cover=`echo outdir/0000-*.patch` &&\n>         mv $cover cover-to-edit.patch &&\n> -       sed \"s/^From:/$header: extra@address.com\\nFrom:/\" cover-to-edit.patch >\"$cover\" &&\n> +       perl -pe \"s/^From:/$header: extra\\@address.com\\nFrom:/\" cover-to-edit.patch >\"$cover\" &&\n>         git send-email \\\n>           --force \\\n>           --from=\"Example <nobody@example.com>\" \\\n> --\n> 2.0.0.553.ged01b91\n"},{"id":"243706","messageId":"xmqqk38pb95s.fsf@gitster.dls.corp.google.com","threadId":"36878","inReplyTo":"5396849F.7060206@web.de","subject":"Re: [PATCH v3] t9001: avoid not portable '\\n' with sed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-06-10T05:55:43Z","receivedAt":"2014-06-10T05:55:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Torsten Bögershausen <tboegi@web.de> writes:\n\n> t9001 used a '\\n' in a sed expression to split one line into two lines,\n> but the usage of '\\n' in the \"replacement string\" is not portable.\n\nThis looks peculiarly familiar; don't I already have it queued?\n"},{"id":"243708","messageId":"5396A618.5040306@web.de","threadId":"36878","inReplyTo":"xmqqk38pb95s.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v3] t9001: avoid not portable '\\n' with sed","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2014-06-10T06:30:48Z","receivedAt":"2014-06-10T06:30:48Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 06/10/2014 07:55 AM, Junio C Hamano wrote:\n> Torsten Bögershausen <tboegi@web.de> writes:\n>\n>> t9001 used a '\\n' in a sed expression to split one line into two lines,\n>> but the usage of '\\n' in the \"replacement string\" is not portable.\n> This looks peculiarly familiar; don't I already have it queued?\nYes, V2 is queued and in pu,and only the commit msg is changed\nbetween V2 and V3.\n\nI think that V3 explains the difference between POSIX sed and\ngnu sed much better, and does reflect all the comments from\nthe list, which otherwise may be lost.\nAnd I suspect that not only the sed under Mac OS X does not\nhandle this very '\\n' different from gnu sed, or in other words,\nmore platforms may not have a gnu sed and may need the fix.\n"},{"id":"243742","messageId":"xmqqmwdkai6u.fsf@gitster.dls.corp.google.com","threadId":"36878","inReplyTo":"5396A618.5040306@web.de","subject":"Re: [PATCH v3] t9001: avoid not portable '\\n' with sed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-06-10T15:38:17Z","receivedAt":"2014-06-10T15:38:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Torsten Bögershausen <tboegi@web.de> writes:\n\n> I think that V3 explains the difference between POSIX sed and\n> gnu sed much better, and does reflect all the comments from\n> the list, which otherwise may be lost.\n\nToo late for that as the patch is already in 'next' X-<.\n"}]}