mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Fix bug that causing terminal corruption if a job is put under job control before running in interactive mode. This is fixed by doing more inits at startup (but only slightly more)
darcs-hash:20060310133809-ac50b-d31cd7bab1a3a58de2833f73735817a3d0b3ed7d.gz
This commit is contained in:
parent
c47dae77a4
commit
32b531667a
7 changed files with 50 additions and 53 deletions
|
@ -2017,10 +2017,10 @@ static int builtin_source( wchar_t ** argv )
|
|||
parser_push_block( SOURCE );
|
||||
reader_push_current_filename( fn_intern );
|
||||
|
||||
|
||||
current_block->param1.source_dest = fn_intern;
|
||||
|
||||
parse_util_set_argv( argv+2);
|
||||
|
||||
res = reader_read( fd );
|
||||
|
||||
parser_pop_block();
|
||||
|
@ -2029,8 +2029,7 @@ static int builtin_source( wchar_t ** argv )
|
|||
sb_printf( sb_err,
|
||||
_( L"%ls: Error while reading file '%ls'\n" ),
|
||||
argv[0],
|
||||
argv[1]
|
||||
);
|
||||
argv[1] );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
12
input.c
12
input.c
|
@ -228,6 +228,8 @@ static int inputrc_block_count=0;
|
|||
*/
|
||||
static int inputrc_error = 0;
|
||||
|
||||
static int is_init = 0;
|
||||
|
||||
wchar_t input_get_code( wchar_t *name )
|
||||
{
|
||||
|
||||
|
@ -1346,6 +1348,11 @@ int input_init()
|
|||
{
|
||||
wchar_t *fn;
|
||||
|
||||
if( is_init )
|
||||
return 1;
|
||||
|
||||
is_init = 1;
|
||||
|
||||
input_common_init( &interrupt_handler );
|
||||
|
||||
if( setupterm( 0, STDOUT_FILENO, 0) == ERR )
|
||||
|
@ -1424,6 +1431,11 @@ static void destroy_mapping( const void *key, const void *val )
|
|||
|
||||
void input_destroy()
|
||||
{
|
||||
if( !is_init )
|
||||
return;
|
||||
|
||||
is_init=0;
|
||||
|
||||
input_common_destroy();
|
||||
|
||||
hash_foreach( &all_mappings, &destroy_mapping );
|
||||
|
|
1
input.h
1
input.h
|
@ -9,6 +9,7 @@ inputrc information for key bindings.
|
|||
#define FISH_INPUT_H
|
||||
|
||||
#include <wchar.h>
|
||||
#include "input_common.h"
|
||||
|
||||
/**
|
||||
Key codes for inputrc-style keyboard functions that are passed on
|
||||
|
|
|
@ -89,16 +89,9 @@ static wint_t readb()
|
|||
case EINTR:
|
||||
case EAGAIN:
|
||||
{
|
||||
// wperror( L"select" );
|
||||
if( interrupt_handler )
|
||||
{
|
||||
int res = interrupt_handler();
|
||||
|
||||
/* debug( 0,
|
||||
L"interrupt, %d is %ls",
|
||||
res,
|
||||
(res==R_NULL?L"good": L"Bad") );
|
||||
*/
|
||||
if( res )
|
||||
return res;
|
||||
}
|
||||
|
@ -143,6 +136,7 @@ static wint_t readb()
|
|||
return arr[0];
|
||||
}
|
||||
|
||||
|
||||
wchar_t input_common_readch( int timed )
|
||||
{
|
||||
if( lookahead_count == 0 )
|
||||
|
|
1
main.c
1
main.c
|
@ -62,6 +62,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "translate.h"
|
||||
#include "halloc_util.h"
|
||||
|
||||
|
||||
/**
|
||||
Parse init files
|
||||
*/
|
||||
|
|
3
proc.c
3
proc.c
|
@ -814,7 +814,6 @@ static void read_try( job_t *j )
|
|||
{
|
||||
b_append( buff->param2.out_buffer, b, l );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -831,7 +830,7 @@ void job_continue (job_t *j, int cont)
|
|||
j->notified = 0;
|
||||
|
||||
debug( 4,
|
||||
L"Continue on job %d (%ls), %ls, %ls",
|
||||
L"Continue job %d (%ls), %ls, %ls",
|
||||
j->job_id,
|
||||
j->command,
|
||||
job_is_completed( j )?L"COMPLETED":L"UNCOMPLETED",
|
||||
|
|
53
reader.c
53
reader.c
|
@ -269,12 +269,6 @@ static struct stat prev_buff_1, prev_buff_2, post_buff_1, post_buff_2;
|
|||
*/
|
||||
static array_list_t prompt_list;
|
||||
|
||||
/**
|
||||
Stores the previous termios mode so we can reset the modes when
|
||||
we execute programs and when the shell exits.
|
||||
*/
|
||||
static struct termios saved_modes;
|
||||
|
||||
|
||||
/**
|
||||
Store the pid of the parent process, so the exit function knows whether it should reset the terminal or not.
|
||||
|
@ -295,6 +289,12 @@ static struct termios old_modes;
|
|||
Prototypes for a bunch of functions defined later on.
|
||||
*/
|
||||
|
||||
/**
|
||||
Stores the previous termios mode so we can reset the modes when
|
||||
we execute programs and when the shell exits.
|
||||
*/
|
||||
static struct termios saved_modes;
|
||||
|
||||
static void reader_save_status();
|
||||
static void reader_check_status();
|
||||
static void reader_super_highlight_me_plenty( wchar_t * buff, int *color, int pos, array_list_t *error );
|
||||
|
@ -841,6 +841,16 @@ static void write_cmdline()
|
|||
|
||||
void reader_init()
|
||||
{
|
||||
tcgetattr(0,&shell_modes); /* get the current terminal modes */
|
||||
memcpy( &saved_modes,
|
||||
&shell_modes,
|
||||
sizeof(saved_modes)); /* save a copy so we can reset the terminal later */
|
||||
|
||||
shell_modes.c_lflag &= ~ICANON; /* turn off canonical mode */
|
||||
shell_modes.c_lflag &= ~ECHO; /* turn off echo mode */
|
||||
shell_modes.c_cc[VMIN]=1;
|
||||
shell_modes.c_cc[VTIME]=0;
|
||||
|
||||
al_init( ¤t_filename);
|
||||
}
|
||||
|
||||
|
@ -854,6 +864,8 @@ void reader_destroy()
|
|||
free( readline_buffer );
|
||||
readline_buffer=0;
|
||||
}
|
||||
tcsetattr(0, TCSANOW, &saved_modes);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1571,18 +1583,6 @@ static int handle_completions( array_list_t *comp )
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Reset the terminal. This function is placed in the list of
|
||||
functions to call when exiting by using the atexit function. It
|
||||
checks whether it is the original parent process that is exiting
|
||||
and not a subshell, and if it is the parent, it restores the
|
||||
terminal.
|
||||
*/
|
||||
static void exit_func()
|
||||
{
|
||||
if( getpid() == original_pid )
|
||||
tcsetattr(0, TCSANOW, &saved_modes);
|
||||
}
|
||||
|
||||
/**
|
||||
Initialize data for interactive use
|
||||
|
@ -1635,16 +1635,6 @@ static void reader_interactive_init()
|
|||
|
||||
common_handle_winch(0);
|
||||
|
||||
tcgetattr(0,&shell_modes); /* get the current terminal modes */
|
||||
memcpy( &saved_modes,
|
||||
&shell_modes,
|
||||
sizeof(saved_modes)); /* save a copy so we can reset the terminal later */
|
||||
|
||||
shell_modes.c_lflag &= ~ICANON; /* turn off canonical mode */
|
||||
shell_modes.c_lflag &= ~ECHO; /* turn off echo mode */
|
||||
shell_modes.c_cc[VMIN]=1;
|
||||
shell_modes.c_cc[VTIME]=0;
|
||||
|
||||
if( tcsetattr(0,TCSANOW,&shell_modes)) /* set the new modes */
|
||||
{
|
||||
wperror(L"tcsetattr");
|
||||
|
@ -1657,9 +1647,6 @@ static void reader_interactive_init()
|
|||
*/
|
||||
original_pid = getpid();
|
||||
|
||||
if( atexit( &exit_func ) )
|
||||
debug( 1, _( L"Could not set exit function" ) );
|
||||
|
||||
env_set( L"_", L"fish", ENV_GLOBAL );
|
||||
}
|
||||
|
||||
|
@ -2799,7 +2786,11 @@ wchar_t *reader_readline()
|
|||
if( (!wchar_private(c)) && (c>31) && (c != 127) )
|
||||
insert_char( c );
|
||||
else
|
||||
{
|
||||
// Carriage returns happen. We ignore them
|
||||
if( c != 13 )
|
||||
debug( 0, _( L"Unknown keybinding %d" ), c );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue