diff options
author | Scott Olson <scott@solson.me> | 2016-02-14T07·50-0600 |
---|---|---|
committer | Scott Olson <scott@solson.me> | 2016-02-14T07·50-0600 |
commit | f30fd9c47b1ae7a48f4854c86b3ad5e038845aa3 (patch) | |
tree | 8e3525a10e57d30b14b77f1c59737d3d7392b72b | |
parent | 2111098a3a26d11edf4452f021245b55287c45b8 (diff) |
Don't consider empty strings or strings beginning with numbers as variable names.
-rw-r--r-- | nix-repl.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/nix-repl.cc b/nix-repl.cc index 5c319f068655..1077f5d8f616 100644 --- a/nix-repl.cc +++ b/nix-repl.cc @@ -250,8 +250,9 @@ static int runProgram(const string & program, const Strings & args) bool isVarName(const string & s) { - if (s.size() > 0 && (s[0] == '-' || s[0] == '\'')) - return false; + if (s.size() == 0) return false; + char c = s[0]; + if ((c >= '0' && c <= '9') || c == '-' || c == '\'') return false; for (auto & i : s) if (!((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z') || |