mirror of
https://github.com/GothenburgBitFactory/taskshell.git
synced 2025-08-23 05:27:50 +02:00
TS-32: control-d to exit
- Thanks to Eric Hymowitz.
This commit is contained in:
parent
346e8881e4
commit
ccd21f4060
4 changed files with 12 additions and 5 deletions
1
AUTHORS
1
AUTHORS
|
@ -21,3 +21,4 @@ suggestions:
|
|||
hosaka
|
||||
Lars Kumbier
|
||||
Iain R. Learmonth
|
||||
Eric Hymowitz
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
- TS-29 tasksh hangs trying to read task from stdin
|
||||
(thanks to ilove zfs).
|
||||
- TS-32 control-d to exit
|
||||
(thanks to Eric Hymowitz).
|
||||
|
||||
------ current release ---------------------------
|
||||
|
||||
|
|
2
NEWS
2
NEWS
|
@ -1,7 +1,7 @@
|
|||
|
||||
New Features in tasksh 1.2.0
|
||||
|
||||
-
|
||||
- Responds to Ctrl-D by exiting.
|
||||
|
||||
New commands in tasksh 1.2.0
|
||||
|
||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -69,6 +69,7 @@ const std::string getResponse (const std::string& prompt)
|
|||
if (! line_read)
|
||||
{
|
||||
std::cout << "\n";
|
||||
response = "<EOF>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -105,12 +106,17 @@ static int commandLoop (bool autoClear)
|
|||
std::cout << "\033[2J\033[0;0H";
|
||||
|
||||
int status = 0;
|
||||
if (command != "")
|
||||
if (! isatty (fileno (stdin)) && command == "")
|
||||
{
|
||||
status = -1;
|
||||
}
|
||||
else if (command != "")
|
||||
{
|
||||
std::vector <std::string> args = split (command, ' ');
|
||||
|
||||
// Dispatch command.
|
||||
if (closeEnough ("exit", args[0], 3)) status = -1;
|
||||
if (args[0] == "<EOF>") status = -1;
|
||||
else if (closeEnough ("exit", args[0], 3)) status = -1;
|
||||
else if (closeEnough ("quit", args[0], 3)) status = -1;
|
||||
else if (closeEnough ("help", args[0], 3)) status = cmdHelp ();
|
||||
else if (closeEnough ("diagnostics", args[0], 3)) status = cmdDiagnostics ();
|
||||
|
@ -127,8 +133,6 @@ static int commandLoop (bool autoClear)
|
|||
// cause the shell to terminate.
|
||||
}
|
||||
}
|
||||
else
|
||||
status = 1;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue