diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-02-24T11·02+0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-02-24T11·02+0100 |
commit | a1ea85e92b067a0a42354a28355c633eac7be65c (patch) | |
tree | 6209da05d615045d0aee74afa0e8168cf57968bc /nix-repl.cc | |
parent | 5599665a270128361862774701ae41fbfba5a661 (diff) | |
parent | 38816759fc7f70605ecfd73304b9d442db388b78 (diff) |
Merge pull request #24 from tsion/whitespace
Fix handling of whitespace and ignore blank inputs.
Diffstat (limited to 'nix-repl.cc')
-rw-r--r-- | nix-repl.cc | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/nix-repl.cc b/nix-repl.cc index 577efa8e2ba5..6f4287a2b698 100644 --- a/nix-repl.cc +++ b/nix-repl.cc @@ -106,7 +106,7 @@ void NixRepl::mainLoop(const Strings & files) } try { - if (!processLine(input)) return; + if (!removeWhitespace(input).empty() && !processLine(input)) return; } catch (ParseError & e) { if (e.msg().find("unexpected $end") != std::string::npos) { // For parse errors on incomplete input, we continue waiting for the next line of @@ -178,14 +178,13 @@ bool NixRepl::getLine(string & input, const char * prompt) char * s = readline(prompt); if (!s) return false; - string line = chomp(string(s)); - input.append(removeWhitespace(line)); + input.append(s); input.push_back('\n'); - free(s); - if (line != "") { - add_history(line.c_str()); + if (!removeWhitespace(s).empty()) { + add_history(s); append_history(1, 0); } + free(s); } _isInterrupted = 0; |