Skip to content

Commit

Permalink
Merge pull request #24 from tsion/whitespace
Browse files Browse the repository at this point in the history
Fix handling of whitespace and ignore blank inputs.
  • Loading branch information
edolstra committed Feb 24, 2016
2 parents 5599665 + 3881675 commit a1ea85e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions nix-repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a1ea85e

Please sign in to comment.