patch 8.2.4970: "eval 123" gives an error, "eval 'abc'" does not
Problem: "eval 123" gives an error, "eval 'abc'" does not.
Solution: Also give an error when evaluating only a string. (closes #10434)
diff --git a/src/ex_eval.c b/src/ex_eval.c
index f3e2ca2..61d2881 100644
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -888,8 +888,8 @@
}
/*
- * Return TRUE if "arg" is only a variable, register, environment variable or
- * option name.
+ * Return TRUE if "arg" is only a variable, register, environment variable,
+ * option name or string.
*/
int
cmd_is_name_only(char_u *arg)
@@ -904,6 +904,17 @@
if (*p != NUL)
++p;
}
+ else if (*p == '\'' || *p == '"')
+ {
+ int r;
+
+ if (*p == '"')
+ r = eval_string(&p, NULL, FALSE, FALSE);
+ else
+ r = eval_lit_string(&p, NULL, FALSE, FALSE);
+ if (r == FAIL)
+ return FALSE;
+ }
else
{
if (*p == '&')