{"thread":{"id":"21728","subject":"[PATCH] t/gitweb-lib: Split HTTP response with non-GNU sed","startedAt":"2009-11-23T17:33:42Z","lastAt":"2009-11-24T16:59:28Z","messageCount":4,"participants":["Brian Gernhardt","Junio C Hamano","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"128181","messageId":"1258997622-62403-1-git-send-email-brian@gernhardtsoftware.com","threadId":"21728","inReplyTo":null,"subject":"[PATCH] t/gitweb-lib: Split HTTP response with non-GNU sed","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2009-11-23T17:33:42Z","receivedAt":"2009-11-23T17:33:42Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"Recognizing \\r in a regex is something GNU sed will do, but other sed\nimplementation's won't.  (Found with BSD sed on OS X.) So use a\nliteral carriage return instead.\n\nSigned-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n---\n t/gitweb-lib.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh\nindex 32b841d..35dda58 100644\n--- a/t/gitweb-lib.sh\n+++ b/t/gitweb-lib.sh\n@@ -52,8 +52,8 @@ gitweb_run () {\n \trm -f gitweb.log &&\n \tperl -- \"$SCRIPT_NAME\" \\\n \t\t>gitweb.output 2>gitweb.log &&\n-\tsed -e   '/^\\r$/q' <gitweb.output >gitweb.headers &&\n-\tsed -e '1,/^\\r$/d' <gitweb.output >gitweb.body    &&\n+\tsed -e   '/^\n$/q' <gitweb.output >gitweb.headers &&\n+\tsed -e '1,/^\n$/d' <gitweb.output >gitweb.body    &&\n \tif grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi\n \n \t# gitweb.log is left for debugging\n-- \n1.6.5.3.433.g11067\n"},{"id":"128190","messageId":"7vocmtyu3v.fsf@alter.siamese.dyndns.org","threadId":"21728","inReplyTo":"1258997622-62403-1-git-send-email-brian@gernhardtsoftware.com","subject":"Re: [PATCH] t/gitweb-lib: Split HTTP response with non-GNU sed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-23T18:27:32Z","receivedAt":"2009-11-23T18:27:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brian Gernhardt <brian@gernhardtsoftware.com> writes:\n\n> Recognizing \\r in a regex is something GNU sed will do, but other sed\n> implementation's won't.  (Found with BSD sed on OS X.) So use a\n> literal carriage return instead.\n\nI'd actually prefer not having to deal with this issue.  How about doing\nsomething like this instead?\n\n t/gitweb-lib.sh |   14 ++++++++++++--\n 1 files changed, 12 insertions(+), 2 deletions(-)\n\ndiff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh\nindex 32b841d..3121950 100644\n--- a/t/gitweb-lib.sh\n+++ b/t/gitweb-lib.sh\n@@ -52,8 +52,18 @@ gitweb_run () {\n \trm -f gitweb.log &&\n \tperl -- \"$SCRIPT_NAME\" \\\n \t\t>gitweb.output 2>gitweb.log &&\n-\tsed -e   '/^\\r$/q' <gitweb.output >gitweb.headers &&\n-\tsed -e '1,/^\\r$/d' <gitweb.output >gitweb.body    &&\n+\tperl -w -e '\n+\t\topen O, \">gitweb.headers\";\n+\t\twhile (<>) {\n+\t\t\tprint O;\n+\t\t\tlast if (/^\\r$/ || /^$/);\n+\t\t}\n+\t\topen O, \">gitweb.body\";\n+\t\twhile (<>) {\n+\t\t\tprint O;\n+\t\t}\n+\t\tclose O;\n+\t' gitweb.output &&\n \tif grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi\n \n \t# gitweb.log is left for debugging\n"},{"id":"128193","messageId":"BF7341BA-DC27-47C6-B140-2D5A074572E7@gernhardtsoftware.com","threadId":"21728","inReplyTo":"7vocmtyu3v.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] t/gitweb-lib: Split HTTP response with non-GNU sed","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2009-11-23T18:50:30Z","receivedAt":"2009-11-23T18:50:30Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"\nOn Nov 23, 2009, at 1:27 PM, Junio C Hamano wrote:\n\n> Brian Gernhardt <brian@gernhardtsoftware.com> writes:\n> \n>> Recognizing \\r in a regex is something GNU sed will do, but other sed\n>> implementation's won't.  (Found with BSD sed on OS X.) So use a\n>> literal carriage return instead.\n> \n> I'd actually prefer not having to deal with this issue.  How about doing\n> something like this instead?\n\nWorks for me.  I just went for the obvious minimal change to make it work.  But since we're testing a perl script, we might as well just use perl to deal with it's output.\n\n~~ Brian\n"},{"id":"128250","messageId":"200911241759.28972.jnareb@gmail.com","threadId":"21728","inReplyTo":"7vocmtyu3v.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] t/gitweb-lib: Split HTTP response with non-GNU sed","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-11-24T16:59:28Z","receivedAt":"2009-11-24T16:59:28Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Mon, 23 Nov 2009, Junio C Hamano wrote:\n> Brian Gernhardt <brian@gernhardtsoftware.com> writes:\n> \n> > Recognizing \\r in a regex is something GNU sed will do, but other sed\n> > implementation's won't.  (Found with BSD sed on OS X.) So use a\n> > literal carriage return instead.\n[...]\n\n> > diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh\n> > index 32b841d..35dda58 100644\n> > --- a/t/gitweb-lib.sh\n> > +++ b/t/gitweb-lib.sh\n> > @@ -52,8 +52,8 @@ gitweb_run () {\n> >         rm -f gitweb.log &&\n> >         perl -- \"$SCRIPT_NAME\" \\\n> >                 >gitweb.output 2>gitweb.log &&\n> > -       sed -e   '/^\\r$/q' <gitweb.output >gitweb.headers &&\n> > -       sed -e '1,/^\\r$/d' <gitweb.output >gitweb.body    &&\n> > +       sed -e   '/^\n> > $/q' <gitweb.output >gitweb.headers &&\n> > +       sed -e '1,/^\n> > $/d' <gitweb.output >gitweb.body    &&\n> >         if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else\n> > true; fi \n> >         # gitweb.log is left for debugging\n\nIf we were to do it this way, I would prefer to set and then use \n'cr' or 'crlf' variable (in sed expression).\n\n> \n> I'd actually prefer not having to deal with this issue.  How about doing\n> something like this instead?\n> \n>  t/gitweb-lib.sh |   14 ++++++++++++--\n>  1 files changed, 12 insertions(+), 2 deletions(-)\n> \n> diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh\n> index 32b841d..3121950 100644\n> --- a/t/gitweb-lib.sh\n> +++ b/t/gitweb-lib.sh\n> @@ -52,8 +52,18 @@ gitweb_run () {\n>  \trm -f gitweb.log &&\n>  \tperl -- \"$SCRIPT_NAME\" \\\n>  \t\t>gitweb.output 2>gitweb.log &&\n> -\tsed -e   '/^\\r$/q' <gitweb.output >gitweb.headers &&\n> -\tsed -e '1,/^\\r$/d' <gitweb.output >gitweb.body    &&\n> +\tperl -w -e '\n\n\"perl\", or \"$PERL\", or \"$PERL_PATH\"?\n\n> +\t\topen O, \">gitweb.headers\";\n\nWell, modern Perl would use here\n\n+\t\topen my $fh, \">\", \"gitweb.headers\";\n\nBut it is not that important here.\n\n> +\t\twhile (<>) {\n> +\t\t\tprint O;\n> +\t\t\tlast if (/^\\r$/ || /^$/);\n> +\t\t}\n> +\t\topen O, \">gitweb.body\";\n> +\t\twhile (<>) {\n> +\t\t\tprint O;\n> +\t\t}\n> +\t\tclose O;\n> +\t' gitweb.output &&\n>  \tif grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi\n>  \n>  \t# gitweb.log is left for debugging\n> \n\nThis is a good solution.  We test Perl script anyway (so Perl is required\nfor running this test), and this way we can do this portably and in one\npass (one fork).\n\n-- \nJakub Narebski\nPoland\n"}]}