Skip to content

Commit f74a83f

Browse files
Benabikgitster
authored andcommitted
t/gitweb-lib: Split HTTP response with non-GNU sed
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>
1 parent b629275 commit f74a83f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

t/gitweb-lib.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,18 @@ gitweb_run () {
5252
rm -f gitweb.log &&
5353
perl -- "$SCRIPT_NAME" \
5454
>gitweb.output 2>gitweb.log &&
55-
sed -e '/^\r$/q' <gitweb.output >gitweb.headers &&
56-
sed -e '1,/^\r$/d' <gitweb.output >gitweb.body &&
55+
perl -w -e '
56+
open O, ">gitweb.headers";
57+
while (<>) {
58+
print O;
59+
last if (/^\r$/ || /^$/);
60+
}
61+
open O, ">gitweb.body";
62+
while (<>) {
63+
print O;
64+
}
65+
close O;
66+
' gitweb.output &&
5767
if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi
5868

5969
# gitweb.log is left for debugging

0 commit comments

Comments
 (0)