Fix IOStreamConsole::askPassword

This commit is contained in:
Sebastian Messmer 2018-09-13 05:09:51 -07:00
parent 804dc89fb7
commit 13f820975a

View File

@ -1,6 +1,7 @@
#include "IOStreamConsole.h" #include "IOStreamConsole.h"
#include <boost/algorithm/string/trim.hpp> #include <boost/algorithm/string/trim.hpp>
#include "DontEchoStdinToStdoutRAII.h" #include "DontEchoStdinToStdoutRAII.h"
#include <cpp-utils/assert/assert.h>
using std::ostream; using std::ostream;
using std::istream; using std::istream;
@ -104,10 +105,7 @@ string IOStreamConsole::askPassword(const string &question) {
std::getline(_input, result); std::getline(_input, result);
_output << std::endl; _output << std::endl;
//Remove trailing newline ASSERT(result.size() == 0 || result[result.size() - 1] != '\n', "Unexpected std::getline() behavior");
if (result[result.size()-1] == '\n') {
result.resize(result.size()-1);
}
return result; return result;
} }