I am writing a bash like program which takes commands and waits for another after it handled the input like this:
my_bash> inc
my_bash> bash error
my_bash>
In case of an error I was printing to cout
and everything was fine, when I changed that to cerr
my program behaves really strange:
cerr << "bash error: cd: OLDPWD not set" << endl;
After the error message gets printed my program doesn't print another line of my_bash>
, and I need to press enter for the other line to show.
like this:
my_bash> inc
my_bash> bash error (in red)
| (cursor here)
then I press enter and get:
my_bash> inc
my_bash> bash error (in red)
my_bash>
what is causing that?
In main.cpp I have:
while(true) {
std::cout << "my_bash> ";
std::string cmd_line;
std::getline(std::cin, cmd_line);
smash.executeCommand(cmd_line.c_str());
}
Aucun commentaire:
Enregistrer un commentaire