Clean up interactive session test

This commit is contained in:
ridiculousfish 2013-10-26 15:24:49 -07:00
parent e05743d0ba
commit 03c65d7a96
2 changed files with 9 additions and 15 deletions

View file

@ -365,18 +365,12 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *out_c
is_login |= (strcmp(argv[0], "-fish") == 0); is_login |= (strcmp(argv[0], "-fish") == 0);
/* /* We are an interactive session if we are either forced, or have not been given an explicit command to execute and stdin is a tty. */
We are an interactive session if we have not been given an if (force_interactive) {
explicit command to execute, _and_ stdin is a tty. is_interactive_session = true;
*/ } else if (is_interactive_session) {
is_interactive_session &= ! has_cmd; is_interactive_session = ! has_cmd && (my_optind == argc) && isatty(STDIN_FILENO);
is_interactive_session &= (my_optind == argc); }
is_interactive_session &= isatty(STDIN_FILENO);
/*
We are also an interactive session if we have are forced-
*/
is_interactive_session |= force_interactive;
return my_optind; return my_optind;
} }
@ -408,7 +402,7 @@ int main(int argc, char **argv)
debug(1, _(L"Can not use the no-execute mode when running an interactive session")); debug(1, _(L"Can not use the no-execute mode when running an interactive session"));
no_exec = 0; no_exec = 0;
} }
/* Only save (and therefore restore) the fg process group if we are interactive. See #197, #1002 */ /* Only save (and therefore restore) the fg process group if we are interactive. See #197, #1002 */
if (is_interactive_session) if (is_interactive_session)
{ {
@ -515,7 +509,7 @@ int main(int argc, char **argv)
} }
proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), res); proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), res);
restore_term_mode(); restore_term_mode();
restore_term_foreground_process_group(); restore_term_foreground_process_group();
history_destroy(); history_destroy();

View file

@ -694,7 +694,7 @@ static void daemonize()
} }
/* /*
Put ourself in out own processing group Put ourself in our own process group
*/ */
setsid(); setsid();