From: Paul Hänsch Date: Thu, 4 Apr 2019 12:19:49 +0000 (+0200) Subject: portable sed invocations X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=8c2e52ffc8910781575126547c067bbd609932bd;p=clickslide portable sed invocations --- diff --git a/cgilite.sh b/cgilite.sh index 7eab08a..ae09497 100755 --- a/cgilite.sh +++ b/cgilite.sh @@ -32,7 +32,7 @@ HEADER(){ # referencing HTTP_* environment variables. if [ -n "${cgilite_headers+x}" ]; then printf %s "$cgilite_headers" \ - | sed -rn 's;^'"${1}"': ([^\r]+)\r?$;\1;i; tX; d; :X;p;q;' + | sed -En 's;^'"${1}"': ([^\r]+)\r?$;\1;i; tX; d; :X;p;q;' else eval "printf %s \"\$HTTP_$(printf %s "${1}" |tr a-z A-Z |tr -c A-Z _)\"" fi @@ -49,7 +49,7 @@ HEX_DECODE=' ' HEX_DECODE(){ - printf -- "$(printf %s "$1" |sed -r "$HEX_DECODE")" + printf -- "$(printf %s "$1" |sed -E "$HEX_DECODE")" } if [ -z "$REQUEST_METHOD" ]; then @@ -116,7 +116,7 @@ cgilite_value(){ str=${str#*&${name}=} cnt=$((cnt - 1)) done - printf -- "$(printf %s "${str%%&*}" |sed -r 's;\+; ;g;'"$HEX_DECODE")" + printf -- "$(printf %s "${str%%&*}" |sed -E 's;\+; ;g;'"$HEX_DECODE")" } cgilite_keys(){ @@ -144,7 +144,7 @@ COOKIE(){ HEX_DECODE "$( HEADER Cookie \ | grep -oE '(^|; ?)'"$1"'=[^;]*' \ - | sed -rn "${2:-1}"'{s;^[^=]+=;;; s;\+; ;g; p;}' + | sed -En "${2:-1}"'{s;^[^=]+=;;; s;\+; ;g; p;}' )" } @@ -165,7 +165,7 @@ HTML(){ 36?) printf '%s' ${n#36};; # 4 octet (21 bit) chain start esac done \ - | sed -r 's;.{7};&\n;g;' \ + | sed -E 's;.{7};&\n;g;' \ | while read n; do printf '&#%d;' $((0$n)) done @@ -182,7 +182,7 @@ URL(){ PATH(){ { [ $# -eq 0 ] && cat || printf %s "$*"; } \ - | sed -r 's;^.*$;/&/;; s;/+;/;g; + | sed -E 's;^.*$;/&/;; s;/+;/;g; :X; s;^/\.\./;/;; s;/\./;/;g; tX;