The option quoted-input means the args are quoted and should be unquoted. At shell command line, we have to quote args first:

-> $ ./redis-cli -p 6383 --quoted-input set a "\x00\x00"
OK
-> $ ./redis-cli -p 6383 --quoted-input get a
"\\x00\\x00"
-> $ ./redis-cli -p 6383 --quoted-input set a "\"\x00\x00\""
OK
-> $ ./redis-cli -p 6383 --quoted-input get a
"\x00\x00"

Is it desirable behavior or a bug. If not read the code, I never know how to use it.

Comment From: yossigo

It's intentional, but confusing (mainly due to the desire to maintain backwards compatibility).

Remember you're actually dealing with two quoting mechanisms here, bash (or other shell) and redis-cli. In the first case, the shell removes the quotes so it's like doing an interactive

127.0.0.1:6379> set key \x00\x00
OK
127.0.0.1:6379> get key
"\\x00\\x00"

In the second case, you're actually passing quotes to redis-cli which indicates you're expecting it to handle special characters:

127.0.0.1:6379> set key "\x00\x00"
OK
127.0.0.1:6379> get key
"\x00\x00"

The purpose of --quoted-input is basically to have redis-cli treat received command line arguments the same way it handles interactive input, and consider quoting rules if enclosed in quotes.

Comment From: huangzhw

Thanks @yossigo. I read the code to understand it. Just want to confirm it.