diff --git a/AUTHORS b/AUTHORS index d235335..1e178c9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -21,3 +21,4 @@ suggestions: hosaka Lars Kumbier Iain R. Learmonth + Eric Hymowitz diff --git a/ChangeLog b/ChangeLog index bf3a024..6da291b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 --------------------------- diff --git a/NEWS b/NEWS index 9962b56..1de0bfd 100644 --- a/NEWS +++ b/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 diff --git a/src/main.cpp b/src/main.cpp index b9c5bae..1134faf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -69,6 +69,7 @@ const std::string getResponse (const std::string& prompt) if (! line_read) { std::cout << "\n"; + response = ""; } 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 args = split (command, ' '); // Dispatch command. - if (closeEnough ("exit", args[0], 3)) status = -1; + if (args[0] == "") 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; }