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>
Brian Gernhardt committed
Nov 23, 2009 at 12:33 UTC
f74a83fcf04c50e8358c8fb493539af13f9b9aa5
1 file changed
+12
-2
t/gitweb-lib.sh
+12
-2
@@ -52,8 +52,18 @@ gitweb_run () {
52
rm -f gitweb.log &&
53
perl -- "$SCRIPT_NAME" \
54
>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 &&
67
if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi
68
69
# gitweb.log is left for debugging