Skip to content

Commit

Permalink
t/gitweb-lib: Split HTTP response with non-GNU sed
Browse files Browse the repository at this point in the history
Recognizing \r in a regex is something GNU sed will do, but other sed
implementation's won't (e.g. BSD sed on OS X).  Instead of two sed
invocations, use a single Perl script to split output into headers
and body.

Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Brian Gernhardt authored and Junio C Hamano committed Nov 24, 2009
1 parent b629275 commit f74a83f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions t/gitweb-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,18 @@ gitweb_run () {
rm -f gitweb.log &&
perl -- "$SCRIPT_NAME" \
>gitweb.output 2>gitweb.log &&
sed -e '/^\r$/q' <gitweb.output >gitweb.headers &&
sed -e '1,/^\r$/d' <gitweb.output >gitweb.body &&
perl -w -e '
open O, ">gitweb.headers";
while (<>) {
print O;
last if (/^\r$/ || /^$/);
}
open O, ">gitweb.body";
while (<>) {
print O;
}
close O;
' gitweb.output &&
if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi

# gitweb.log is left for debugging
Expand Down

0 comments on commit f74a83f

Please sign in to comment.