From 9f7c0932d1f5a727003a9876be219c155692ab07 Mon Sep 17 00:00:00 2001 From: Mikhail Novosyolov Date: Tue, 16 Apr 2024 16:00:52 +0300 Subject: [PATCH] use bash built-in printf and echo to speed up things, no need in external binaries --- bashlib.in | 22 +++++++++++----------- configure.in | 2 -- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/bashlib.in b/bashlib.in index 6ee50e8..3caff41 100644 --- a/bashlib.in +++ b/bashlib.in @@ -36,7 +36,7 @@ fi if [ -n "${QUERY_STRING}" ]; then # name=value params, separated by either '&' or ';' if echo ${QUERY_STRING} | grep '=' >/dev/null ; then - for Q in $(@ECHO@ ${QUERY_STRING} | @TR@ ";&" "\012") ; do + for Q in $(echo ${QUERY_STRING} | @TR@ ";&" "\012") ; do # # Clear our local variables # @@ -48,12 +48,12 @@ if [ -n "${QUERY_STRING}" ]; then # get the name of the key, and decode it # name=${Q%%=*} - name=$(@ECHO@ ${name} | \ + name=$(echo ${name} | \ @SED@ -e 's/%\(\)/\\\x/g' | \ @TR@ "+" " ") - name=$(@ECHO@ ${name} | \ + name=$(echo ${name} | \ @TR@ -d ".-") - name=$(@PRINTF@ ${name} | @TR@ -d '$`') + name=$(printf ${name} | @TR@ -d '$`') # # get the value and decode it. This is tricky... printf chokes on @@ -63,7 +63,7 @@ if [ -n "${QUERY_STRING}" ]; then # printf, and then remove it. # tmpvalue=${Q#*=} - tmpvalue=$(@ECHO@ ${tmpvalue} | \ + tmpvalue=$(echo ${tmpvalue} | \ @SED@ -e 's/%\(..\)/\\\x\1 /g') #echo "Intermediate \$value: ${tmpvalue}" 1>&2 @@ -72,7 +72,7 @@ if [ -n "${QUERY_STRING}" ]; then # value # for i in ${tmpvalue}; do - g=$(@PRINTF@ ${i}) + g=$(printf ${i}) value="${value}${g}" done #value=$(echo ${value}) @@ -110,17 +110,17 @@ if [ -n "${HTTP_COOKIE}" ]; then # get the name of the key, and decode it # name=${Q%%=*} - name=$(@ECHO@ ${name} | \ + name=$(echo ${name} | \ @SED@ -e 's/%\(\)/\\\x/g' | \ @TR@ "+" " ") - name=$(@ECHO@ ${name} | \ + name=$(echo ${name} | \ @TR@ -d ".-") - name=$(@PRINTF@ ${name}) + name=$(printf ${name}) # Decode the cookie value. See the parameter section above for # an explanation of what this is doing. tmpvalue=${Q#*=} - tmpvalue=$(@ECHO@ ${tmpvalue} | \ + tmpvalue=$(echo ${tmpvalue} | \ @SED@ -e 's/%\(..\)/\\\x\1 /g') #echo "Intermediate \$value: ${tmpvalue}" 1>&2 @@ -129,7 +129,7 @@ if [ -n "${HTTP_COOKIE}" ]; then # value # for i in ${tmpvalue}; do - g=$(@PRINTF@ ${i}) + g=$(printf ${i}) value="${value}${g}" done #value=$(echo ${value}) diff --git a/configure.in b/configure.in index 68c2783..4d2bb24 100644 --- a/configure.in +++ b/configure.in @@ -34,13 +34,11 @@ AC_PATH_PROG(AWK, awk, "") AC_PATH_PROG(CAT, cat, "") AC_PATH_PROG(CUT, cut, "") AC_PATH_PROG(CP, cp, "") -AC_PATH_PROG(ECHO, echo, "") AC_PATH_PROG(ENV, env, "") AC_PATH_PROG(GREP, grep, "") AC_PATH_PROG(GZIP, gzip, "") AC_PATH_PROG(INSTALL, install, "") AC_PATH_PROG(MKDIR, mkdir, "") -AC_PATH_PROG(PRINTF, printf, "") AC_PATH_PROG(RM, rm, "") AC_PATH_PROG(SED, sed, "") AC_PATH_PROG(TAR, tar, "")