From 4db76437046e244e64daa5b4b03fe0a3c32fc81a Mon Sep 17 00:00:00 2001 From: Nicholas Chambers Date: Sat, 2 May 2020 16:11:46 -0500 Subject: [PATCH] Add support for the nil type and empty arrays --- lib/serv.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/serv.sh b/lib/serv.sh index 5e731d0..eaf57cd 100644 --- a/lib/serv.sh +++ b/lib/serv.sh @@ -42,12 +42,25 @@ parse_err() { } parse_bulk() { - bulk=1 + if [[ $1 = \$-1 ]]; then + (( lines_left -= 1 )) + printf '(nil)\n' + else + bulk=1 + fi } parse_arr() { - lines_left=${1:1} - arr=1 + if [[ $1 = \*-1 ]]; then + (( lines_left -= 1 )) + printf '(nil)\n' + elif [[ $1 = \*0 ]]; then + (( lines_left -= 1 )) + printf '(empty array)\n' + else + lines_left=${1:1} + arr=1 + fi } parse_other() {