mirror of
https://github.com/GothenburgBitFactory/taskshell.git
synced 2025-06-26 10:54:29 +02:00
Tasksh
- When Ctrl-D is entered, std::cin is closed. Now detects this and terminates.
This commit is contained in:
parent
70454c35b9
commit
ac4d4d3a76
1 changed files with 6 additions and 3 deletions
|
@ -71,11 +71,14 @@ static int commandLoop ()
|
||||||
std::string command (line_read);
|
std::string command (line_read);
|
||||||
free (line_read);
|
free (line_read);
|
||||||
#else
|
#else
|
||||||
// TODO When Ctrl-D is pressed, it closeѕ std::cin, which causes this loop
|
|
||||||
// to cycle very quickly with no input. Perhaps reopen std::cin?
|
|
||||||
std::cout << prompt;
|
std::cout << prompt;
|
||||||
std::string command;
|
std::string command;
|
||||||
std::getline (std::cin, command);
|
std::getline (std::cin, command);
|
||||||
|
if (std::cin.eof () == 1)
|
||||||
|
{
|
||||||
|
std::cout << "\n";
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Dispatch command
|
// Dispatch command
|
||||||
|
@ -84,7 +87,7 @@ static int commandLoop ()
|
||||||
else if (closeEnough ("quit", command, 3)) status = 1;
|
else if (closeEnough ("quit", command, 3)) status = 1;
|
||||||
else if (closeEnough ("help", command, 3)) status = cmdHelp ();
|
else if (closeEnough ("help", command, 3)) status = cmdHelp ();
|
||||||
else if (closeEnough ("diagnostics", command, 3)) status = cmdDiagnostics ();
|
else if (closeEnough ("diagnostics", command, 3)) status = cmdDiagnostics ();
|
||||||
else
|
else if (command != "")
|
||||||
{
|
{
|
||||||
std::cout << "[task " << command << "]\n";
|
std::cout << "[task " << command << "]\n";
|
||||||
command = "task " + command;
|
command = "task " + command;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue