mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Fix bug in exit code that made the exit builtin exit even if there where running jobs if called directly from the commandline
darcs-hash:20070926090159-75c98-2760c6c24e21fd14711c9ce3bef1b0890b495d65.gz
This commit is contained in:
parent
df4fdf33c4
commit
093cb71f91
2 changed files with 83 additions and 57 deletions
127
reader.c
127
reader.c
|
@ -2150,6 +2150,68 @@ int exit_status()
|
|||
return end_loop;
|
||||
}
|
||||
|
||||
/**
|
||||
This function is called when the main loop notices that end_loop
|
||||
has been set while in interactive mode. It checks if it is ok to
|
||||
exit.
|
||||
*/
|
||||
|
||||
static void handle_end_loop()
|
||||
{
|
||||
job_t *j;
|
||||
int job_count=0;
|
||||
int is_breakpoint=0;
|
||||
block_t *b;
|
||||
|
||||
for( b = current_block;
|
||||
b;
|
||||
b = b->outer )
|
||||
{
|
||||
if( b->type == BREAKPOINT )
|
||||
{
|
||||
is_breakpoint = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for( j=first_job; j; j=j->next )
|
||||
{
|
||||
if( !job_is_completed(j) )
|
||||
{
|
||||
job_count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !reader_exit_forced() && !data->prev_end_loop && job_count && !is_breakpoint )
|
||||
{
|
||||
writestr(_( L"There are stopped jobs\n" ));
|
||||
|
||||
reader_exit( 0, 0 );
|
||||
data->prev_end_loop=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !isatty(0) )
|
||||
{
|
||||
/*
|
||||
We already know that stdin is a tty since we're
|
||||
in interactive mode. If isatty returns false, it
|
||||
means stdin must have been closed.
|
||||
*/
|
||||
for( j = first_job; j; j=j->next )
|
||||
{
|
||||
if( ! job_is_completed( j ) )
|
||||
{
|
||||
job_signal( j, SIGHUP );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Read interactively. Read input from stdin while providing editing
|
||||
facilities.
|
||||
|
@ -2186,58 +2248,7 @@ static int read_i()
|
|||
|
||||
if( data->end_loop)
|
||||
{
|
||||
job_t *j;
|
||||
int has_job=0;
|
||||
int is_breakpoint=0;
|
||||
block_t *b;
|
||||
|
||||
for( b = current_block;
|
||||
b;
|
||||
b = b->outer )
|
||||
{
|
||||
if( b->type == BREAKPOINT )
|
||||
{
|
||||
is_breakpoint = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for( j=first_job; j; j=j->next )
|
||||
{
|
||||
if( !job_is_completed(j) )
|
||||
{
|
||||
has_job = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !reader_exit_forced() && !data->prev_end_loop && has_job && !is_breakpoint )
|
||||
{
|
||||
writestr(_( L"There are stopped jobs\n" ));
|
||||
|
||||
reader_exit( 0, 0 );
|
||||
data->prev_end_loop=1;
|
||||
|
||||
repaint();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !isatty(0) )
|
||||
{
|
||||
/*
|
||||
We already know that stdin is a tty since we're
|
||||
in interactive mode. If isatty returns false, it
|
||||
means stdin must have been closed.
|
||||
*/
|
||||
for( j = first_job; j; j=j->next )
|
||||
{
|
||||
if( ! job_is_completed( j ) )
|
||||
{
|
||||
job_signal( j, SIGHUP );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
handle_end_loop();
|
||||
}
|
||||
else if( tmp )
|
||||
{
|
||||
|
@ -2247,10 +2258,17 @@ static int read_i()
|
|||
data->buff[data->buff_len]=L'\0';
|
||||
reader_run_command( tmp );
|
||||
free( tmp );
|
||||
|
||||
data->prev_end_loop=0;
|
||||
if( data->end_loop)
|
||||
{
|
||||
handle_end_loop();
|
||||
}
|
||||
else
|
||||
{
|
||||
data->prev_end_loop=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
reader_pop();
|
||||
return 0;
|
||||
|
@ -2447,6 +2465,7 @@ wchar_t *reader_readline()
|
|||
|
||||
case R_NULL:
|
||||
{
|
||||
repaint();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,18 @@
|
|||
#
|
||||
|
||||
function delete-or-exit
|
||||
|
||||
set -l cmd (commandline)
|
||||
if test "$cmd"
|
||||
commandline -f delete-char
|
||||
else
|
||||
|
||||
switch $cmd
|
||||
|
||||
case ''
|
||||
exit 0
|
||||
|
||||
case '*'
|
||||
commandline -f delete-char
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue