53 lines
525 B
Bash
Executable file
53 lines
525 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
###
|
|
# defaults
|
|
###
|
|
|
|
host=127.0.0.1
|
|
port=6379
|
|
table=0
|
|
|
|
###
|
|
# config
|
|
###
|
|
|
|
if (( $# )); then
|
|
. "$1"
|
|
shift
|
|
fi
|
|
|
|
###
|
|
# load library
|
|
###
|
|
|
|
. "${REDISH_LIB_PATH:-.}"/redi.sh
|
|
|
|
###
|
|
# cleanup on exit
|
|
###
|
|
|
|
trap cleanup EXIT
|
|
|
|
###
|
|
# driver
|
|
###
|
|
|
|
while get_cmd line; do
|
|
redis_cmd=( )
|
|
|
|
parse_cmd redis_line "$line"
|
|
|
|
if [[ ${redis_cmd[0]} = EXIT ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
redis_send "$redis_line"
|
|
|
|
lines_left=1
|
|
bulk=0 arr=0
|
|
|
|
while (( lines_left )) && redis_recv line; do
|
|
parse_res "$line"
|
|
done
|
|
done
|