From bd17ccf1d822ba76cdd58e9547bc18db35189c55 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 26 Dec 2017 19:22:28 -0600 Subject: nix repl: use linenoiseKeyType to differentiate ^C and ^D Fixes #1757. --- src/nix/repl.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/nix/repl.cc') diff --git a/src/nix/repl.cc b/src/nix/repl.cc index 1adb816c5bf0..9216209173d9 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; } -- cgit 1.4.1