]> git.plutz.net Git - clickslide/commitdiff
independence from GNU `sed`, set CR and BR without forking subshell
authorPaul Hänsch <paul@plutz.net>
Thu, 2 Aug 2018 11:51:17 +0000 (13:51 +0200)
committerPaul Hänsch <paul@plutz.net>
Thu, 2 Aug 2018 11:51:17 +0000 (13:51 +0200)
cgilite.sh

index 996fe9daa4befceac6e7461b7e4755e03feebe9c..e0d4b9392cda8709e80509b176961957ce0008ca 100755 (executable)
@@ -22,8 +22,9 @@
 # set -o posix # ksh, not portable
 setopt -o OCTAL_ZEROES 2>&-
 
-BR="$(printf '\n')"
-CR="$(printf '\r')"
+CR="\r"
+BR='
+'
 cgilite_timeout=2
 
 HEADER(){
@@ -70,7 +71,7 @@ if [ -z "$REQUEST_METHOD" ]; then
     kill $cgilite_watchdog
     PATH_INFO="$(HEX_DECODE "${REQUEST_URI%\?*}")"
     QUERY_STRING="${REQUEST_URI#*\?}"
-    cgilite_headers="$(sed -u '/^\r\?$/q')"
+    cgilite_headers="$(while read -r hl; do [ "${hl%${CR}}" ] && printf '%s\n' "$hl" || break; done )"
 
     HTTP_CONTENT_LENGTH="$(HEADER Content-Length |grep -xE '[0-9]+')"