Merge branch 'fix/issue-1757' of git://github.com/dtzWill/nix

This commit is contained in:
Shea Levy 2017-12-27 18:51:05 -05:00
commit 6a0dd63508
No known key found for this signature in database
GPG key ID: 5C0BD6957D86FE27

View file

@ -186,7 +186,16 @@ bool NixRepl::getLine(string & input, const std::string &prompt)
{ {
char * s = linenoise(prompt.c_str()); char * s = linenoise(prompt.c_str());
Finally doFree([&]() { free(s); }); 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; input += s;
return true; return true;
} }