diff --git a/src/scripting.c b/src/scripting.c index 6f3f52ba..fb1ae9c6 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -1145,7 +1145,7 @@ int luaCreateFunction(client *c, lua_State *lua, char *funcname, robj *body) { funcdef = sdscatlen(funcdef,funcname,42); funcdef = sdscatlen(funcdef,"() ",3); funcdef = sdscatlen(funcdef,body->ptr,sdslen(body->ptr)); - funcdef = sdscatlen(funcdef," end",4); + funcdef = sdscatlen(funcdef,"\nend",4); if (luaL_loadbuffer(lua,funcdef,sdslen(funcdef),"@user_script")) { addReplyErrorFormat(c,"Error compiling script (new function): %s\n", diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index d515c3a5..0efe86ad 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -272,6 +272,10 @@ start_server {tags {"scripting"}} { } 0 } {} + test {EVAL - Able to parse trailing comments} { + r eval {return 'hello' --trailing comment} 0 + } {hello} + test {SCRIPTING FLUSH - is able to clear the scripts cache?} { r set mykey myval set v [r evalsha fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey]