Add another variable for storing the command sent to Redis

This commit is contained in:
Nicholas Chambers 2020-05-02 14:55:19 -05:00
parent c56d452dc1
commit 61ccf79c25
2 changed files with 13 additions and 7 deletions

View File

@ -6,14 +6,14 @@ get_cmd() {
parse_cmd() {
local cmd=( ) arg
declare -n serialized=$1
declare -n cmd_sent=$1
declare -n serialized=$2
route_cmd "$2"
route_cmd "$3"
serialized=*${#cmd[@]}$'\r\n'
serialized+=${cmd[0]^^}
for arg in "${cmd[@]:1}"; do
for arg in "${cmd[@]}"; do
serialized+=$arg
done
}
@ -55,6 +55,12 @@ parse_word() {
fi
done
cmd+=( "\$${#arg}"$'\r\n'"$arg"$'\r\n' )
if ! (( ${#cmd[@]} )); then
cmd_sent=${arg^^}
cmd+=( "\$${#arg}"$'\r\n'"$cmd_sent"$'\r\n' )
else
cmd+=( "\$${#arg}"$'\r\n'"$arg"$'\r\n' )
fi
route_cmd "$line"
}

View File

@ -28,6 +28,6 @@ fi
###
while get_cmd line; do
parse_cmd redis_cmd "$line"
redis_send "$redis_cmd"
parse_cmd redis_cmd redis_line "$line"
redis_send "$redis_line"
done