From c830b47570c441da2e854ea4b3538fc5b87e8f0a Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Fri, 8 Apr 2016 22:14:07 -0700 Subject: [PATCH] authrequired/git-daemon-verify: eliminate use of wc -c A POSIX-compatible shell provides a convenient ${#var} construct to determine the length in characters of a variable's value. Use it instead of wc -c to eliminate unnecessary overhead. Signed-off-by: Kyle J. McKay --- bin/git-daemon-verify | 4 ++-- cgi/authrequired.cgi | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/git-daemon-verify b/bin/git-daemon-verify index 491466c..39b3267 100755 --- a/bin/git-daemon-verify +++ b/bin/git-daemon-verify @@ -25,8 +25,8 @@ fi errormsg() { - _l=$(printf 'xxxxERR %s' "$*" | wc -c) - printf '%04xERR %s' $_l "$*" + _l="$*" + printf '%04xERR %s' $(( 8 + ${#_l} )) "$_l" } invalbaderr() diff --git a/cgi/authrequired.cgi b/cgi/authrequired.cgi index 27e4b75..284fd33 100755 --- a/cgi/authrequired.cgi +++ b/cgi/authrequired.cgi @@ -149,8 +149,8 @@ of your private key (see the above page). ====================================================================== " if [ -n "$isoldgit" -a -n "$service" ]; then - l1=$(printf 'xxxx# service=%s\n' "$service" | wc -c) - l2=$(printf 'xxxxERR \n%s' "$message" | wc -c) + l1=$(( 15 + ${#service} )) + l2=$(( 9 + ${#message} )) headers 200 "application/x-$service-advertisement" \ "Content-Length: $(( $l1 + 4 + $l2 ))" printf '%04x# service=%s\n0000%04xERR \n%s' $l1 "$service" \ -- 2.11.4.GIT