diff --git a/src/notORM.sh b/src/notORM.sh index 0adf36e..81a0bcd 100755 --- a/src/notORM.sh +++ b/src/notORM.sh @@ -70,17 +70,17 @@ alias _data_parse_pairs=' _data_gen_expr() { # we need the pairs sorted due to how the sed expr generation works local IFS=$'\01\n' - local i sorted + local i sorted=($(for (( i=0; i<${#search[@]}; i++ )); do echo "${column[i]}"$'\01'"${search[i]}" done | sort -n -t$'\01')) local last=0 for (( i=0; i<${#sorted[@]}; i=i+2 )); do - if [[ $((sorted[i] - last)) -le 1 && $i != 0 ]]; then + if [[ $((sorted[i] - last)) -le 1 ]]; then expr+="$(_sed_sanitize "${sorted[i+1]}")${delim}" else - expr+="$(repeat $((sorted[i] - last)) "[^${delim}]*${delim}")$(_sed_sanitize "${sorted[i+1]}")${delim}" + expr+="$(repeat $((sorted[i] - last)) ".*$delim")$(_sed_sanitize "${sorted[i+1]}")${delim}" fi last="${sorted[i]}" done @@ -238,7 +238,7 @@ data_replace_value() { if [[ $column == 0 ]]; then local expr="s$ctrl^$(_sed_sanitize "$2")\(${delim}.*\)$ctrl$(_sed_sanitize "$3")\1$ctrl" else - local expr="s$ctrl^\($(repeat $column "[^${delim}]*${delim}")\)$(_sed_sanitize "$2")\($delim$(repeat $(( $(cat "${1}.cols") - column - 1 )) "[^${delim}]*${delim}")\)"'$'"$ctrl\1$(_sed_sanitize "$3")\2$ctrl" + local expr="s$ctrl^\($(repeat $column ".*$delim")\)$(_sed_sanitize "$2")\($delim$(repeat $(( $(cat "${1}.cols") - column - 1 )) ".*$delim")\)"'$'"$ctrl\1$(_sed_sanitize "$3")\2$ctrl" fi sed -i "$expr" "$1" @@ -273,7 +273,7 @@ data_replace() { if [[ $column == 0 ]]; then local expr="s$ctrl^$(_sed_sanitize "$2")${delim}.*$ctrl" else - local expr="s$ctrl^$(repeat $column "[^${delim}]*${delim}")$(_sed_sanitize "$2")$delim$(repeat $(( $(cat "${store}.cols") - column - 1 )) "[^${delim}]*${delim}")"'$'"$ctrl" + local expr="s$ctrl^$(repeat $column ".*$delim")$(_sed_sanitize "$2")$delim$(repeat $(( $(cat "${store}.cols") - column - 1 )) ".*$delim")"'$'"$ctrl" fi # fi @@ -310,7 +310,7 @@ data_yeet() { if [[ $column == 0 ]]; then local expr="/^$(_sed_sanitize "$2")${delim}.*/d" else - local expr="/^$(repeat $column "[^${delim}]*${delim}")$(_sed_sanitize "$2")$delim$(repeat $(( $(cat "${store}.cols") - column - 1 )) "[^${delim}]*${delim}")"'$'"/d" + local expr="/^$(repeat $column ".*$delim")$(_sed_sanitize "$2")$delim$(repeat $(( $(cat "${store}.cols") - column - 1 )) ".*$delim")"'$'"/d" fi fi diff --git a/tests/01-http-basic.sh b/tests/01-http-basic.sh index e769f43..04722bf 100644 --- a/tests/01-http-basic.sh +++ b/tests/01-http-basic.sh @@ -60,49 +60,9 @@ EOF match="nyaa" } -server_patch_dummy() { - prepare() { - cat <<"EOF" > app/webroot/meow.shs -#!/bin/bash -echo "${r[method]}" -EOF - } - - tst() { - curl -s "localhost:1337/meow.shs" -X PATCH - } - - match="PATCH" -} - -server_put_dummy() { - tst() { - curl -s "localhost:1337/meow.shs" -X PUT - } - - match="PUT" -} - -server_delete_dummy() { - tst() { - curl -s "localhost:1337/meow.shs" -X DELETE - } - - match="DELETE" -} - -server_head() { - # known to fail; TODO for another day - tst() { - curl -s -I localhost:1337 - } - - match_sub="HTTP.sh" -} - server_res_header() { tst() { - curl -s -v localhost:1337 2>&1 + curl -s -I localhost:1337 } match_sub="HTTP.sh" @@ -202,14 +162,6 @@ subtest_list=( server_get_param server_post_param - # currently functionally equivalent - server_patch_dummy - server_put_dummy - server_delete_dummy - - ## currently broken, TODO - # server_head - server_res_header server_res_header_custom diff --git a/tests/04-notORM.sh b/tests/04-notORM.sh index afde06d..995f6ba 100644 --- a/tests/04-notORM.sh +++ b/tests/04-notORM.sh @@ -83,7 +83,7 @@ notORM_replace_oldsyntax() { data_get "$store" { } out out[2]='meow!' data_replace "$store" 4 out 1 || return $? - data_get "$store" 4 1 || return $? + data_get "$store" 4 || return $? [[ "${res[@]}" == "${out[@]}" ]] && return 0 || return 1 } } diff --git a/tst.sh b/tst.sh index 52d8171..bb50350 100755 --- a/tst.sh +++ b/tst.sh @@ -1,10 +1,4 @@ #!/usr/bin/env bash -trap ctrl_c INT -ctrl_c() { - pkill -P $$ - echo -e "Interrupted and cleaned up." - return 255 -} _defaults() { match="" @@ -58,7 +52,6 @@ on_fatal() { IFS=$'\n' for i in "$@"; do if [[ ! -f "$i" ]]; then - echo "ENOENT: $i" echo -e "$0 - basic test framework\n\nusage: $0 [test] [...]" exit 1 fi @@ -123,12 +116,10 @@ _final_cleanup() { for i in $(jobs -p); do pkill -P $i done - if [[ "$(jobs -p)" != '' ]]; then - sleep 1 - for i in $(jobs -p); do - pkill -9 -P $i - done - fi + sleep 2 + for i in $(jobs -p); do + pkill -9 -P $i + done pkill -P $$ }