redis-cli strips newline while loading script

Created on 14 Sep 2012  路  2Comments  路  Source: redis/redis

Discussion: https://groups.google.com/d/topic/redis-db/pXPQ2Dk0WFc/discussion

Summary:

redis-cli strips the newline at the end of a script while loading scripts as follows:
$ redis-cli script load "$(cat /path/to/script.lua)"

This makes the SHA1 digest obtained from redis and by the commandline utility sha1sum differ.

It would be nice if redis-cli didn't do this since it is convenient to generate digests from the commandline and distribute them to the users of the scripts without even loading them to redis. It would also make digests returned from redis compatible with the commandline utility sha1sum.

Most helpful comment

Your shell removes the newline. Bash does this according to its internal IFS variable, that determines how data is split.

You can make redis-cli read the last argument from STDIN to bypass this. For example:

$ cat /path/to/scriptfile.lua | redis-cli -x script load

All 2 comments

Your shell removes the newline. Bash does this according to its internal IFS variable, that determines how data is split.

You can make redis-cli read the last argument from STDIN to bypass this. For example:

$ cat /path/to/scriptfile.lua | redis-cli -x script load

thanks for the explanation

Was this page helpful?
0 / 5 - 0 ratings