aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2017-12-27 18:51:05 -0500
committerShea Levy <shea@shealevy.com>2017-12-27 18:51:05 -0500
commit6a0dd635084213bf75c1f36bc9bc38d242096e65 (patch)
tree0770dac8fff39aa9bac16991402ede84adccc80c
parent25196d0d26cf4ebe68099ebb28d287177425d307 (diff)
parentbd17ccf1d822ba76cdd58e9547bc18db35189c55 (diff)
Merge branch 'fix/issue-1757' of git://github.com/dtzWill/nix
-rw-r--r--src/nix/repl.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index 1adb816c5..921620917 100644
--- a/src/nix/repl.cc
+++ b/src/nix/repl.cc
@@ -186,7 +186,16 @@ bool NixRepl::getLine(string & input, const std::string &prompt)
{
char * s = linenoise(prompt.c_str());
Finally doFree([&]() { free(s); });
- if (!s) return false;
+ if (!s) {
+ switch (auto type = linenoiseKeyType()) {
+ case 1: // ctrl-C
+ return true;
+ case 2: // ctrl-D
+ return false;
+ default:
+ throw Error(format("Unexpected linenoise keytype: %1%") % type);
+ }
+ }
input += s;
return true;
}