about summary refs log tree commit diff
diff options
context:
space:
mode:
authorScott Olson <scott@solson.me>2016-02-24T00·29-0600
committerScott Olson <scott@solson.me>2016-02-24T00·29-0600
commit87e6649fc30a37adabf384a68f588de946bc3468 (patch)
tree2ec8ed37494b6eaecd5dcd1c9cb7499c85a74f60
parent5599665a270128361862774701ae41fbfba5a661 (diff)
Fix handling of whitespace.
Whitespace will no longer be removed from input lines, which fixes pasting
multiline strings containing end-of-line or beginning-of-line whitespace.
-rw-r--r--nix-repl.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/nix-repl.cc b/nix-repl.cc
index 577efa8e2ba5..1cdff20fd41d 100644
--- a/nix-repl.cc
+++ b/nix-repl.cc
@@ -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;