about summary refs log tree commit diff
path: root/nix-repl.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-15T09·25+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-15T09·25+0100
commitdc8b51754b1531ce15dd47cc727ea52b34680bff (patch)
tree8e3525a10e57d30b14b77f1c59737d3d7392b72b /nix-repl.cc
parent8a2f5f0607540ffe56b56d52db544373e1efb980 (diff)
parentf30fd9c47b1ae7a48f4854c86b3ad5e038845aa3 (diff)
Merge pull request #16 from tsion/dashed-assign
Improve variable name parsing for assignments.
Diffstat (limited to 'nix-repl.cc')
-rw-r--r--nix-repl.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/nix-repl.cc b/nix-repl.cc
index 474ad4fc9afd..1077f5d8f616 100644
--- a/nix-repl.cc
+++ b/nix-repl.cc
@@ -250,12 +250,14 @@ static int runProgram(const string & program, const Strings & args)
 
 bool isVarName(const string & s)
 {
-    // FIXME: not quite correct.
+    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') ||
               (i >= '0' && i <= '9') ||
-              i == '_' || i == '\''))
+              i == '_' || i == '-' || i == '\''))
             return false;
     return true;
 }