mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
Fix a number of bugs found using the warnings generated by earlier patch
darcs-hash:20061019153603-ac50b-4efb1ad1fe2cbe693a921648a0616a3d258d7933.gz
This commit is contained in:
parent
ae16397e1c
commit
4683f4c989
8 changed files with 188 additions and 155 deletions
31
complete.c
31
complete.c
|
@ -909,8 +909,8 @@ static const wchar_t *complete_get_desc_suffix( const wchar_t *suff_orig )
|
|||
array_list_t l;
|
||||
al_init( &l );
|
||||
|
||||
exec_subshell( cmd, &l );
|
||||
free(cmd);
|
||||
if( exec_subshell( cmd, &l ) != -1 )
|
||||
{
|
||||
|
||||
if( al_get_count( &l )>0 )
|
||||
{
|
||||
|
@ -926,7 +926,9 @@ static const wchar_t *complete_get_desc_suffix( const wchar_t *suff_orig )
|
|||
desc[0]=towupper(desc[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(cmd);
|
||||
al_foreach( &l, &free );
|
||||
al_destroy( &l );
|
||||
}
|
||||
|
@ -1155,7 +1157,9 @@ static void complete_cmd_desc( const wchar_t *cmd, array_list_t *comp )
|
|||
systems with a large set of manuals, but it should be ok
|
||||
since apropos is only called once.
|
||||
*/
|
||||
exec_subshell( lookup_cmd, &list );
|
||||
if( exec_subshell( lookup_cmd, &list ) != -1 )
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
Then discard anything that is not a possible completion and put
|
||||
|
@ -1227,6 +1231,7 @@ static void complete_cmd_desc( const wchar_t *cmd, array_list_t *comp )
|
|||
*cmd_end = COMPLETE_SEP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hash_destroy( &lookup );
|
||||
al_foreach( &list,
|
||||
|
@ -1798,16 +1803,18 @@ static void complete_param_expand( wchar_t *str,
|
|||
{
|
||||
comp_str = str;
|
||||
}
|
||||
/*
|
||||
debug( 3,
|
||||
L"expand_string( \"%ls\", comp_out, EXPAND_SKIP_CMDSUBST | ACCEPT_INCOMPLETE | %ls );",
|
||||
comp_str,
|
||||
do_file?L"0":L"EXPAND_SKIP_WILDCARDS" );
|
||||
*/
|
||||
expand_string( 0,
|
||||
|
||||
if( expand_string( 0,
|
||||
wcsdup(comp_str),
|
||||
comp_out,
|
||||
EXPAND_SKIP_CMDSUBST | ACCEPT_INCOMPLETE | (do_file?0:EXPAND_SKIP_WILDCARDS) );
|
||||
EXPAND_SKIP_CMDSUBST | ACCEPT_INCOMPLETE | (do_file?0:EXPAND_SKIP_WILDCARDS) ) )
|
||||
{
|
||||
/*
|
||||
Ignore errors - completions may fail, and that's ok
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1974,7 +1981,7 @@ static int try_complete_user( const wchar_t *cmd,
|
|||
L"/",
|
||||
COMPLETE_SEP_STR,
|
||||
COMPLETE_USER_DESC,
|
||||
0 );
|
||||
(void *)0 );
|
||||
if( blarg != 0 )
|
||||
{
|
||||
al_push( comp, blarg );
|
||||
|
|
12
exec.c
12
exec.c
|
@ -1344,7 +1344,7 @@ int exec_subshell( const wchar_t *cmd,
|
|||
debug( 1,
|
||||
_( L"Sent null command to subshell. This is a fish bug. If it can be reproduced, please send a bug report to %s." ),
|
||||
PACKAGE_BUGREPORT );
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
is_subshell=1;
|
||||
|
@ -1352,11 +1352,17 @@ int exec_subshell( const wchar_t *cmd,
|
|||
|
||||
prev_status = proc_get_last_status();
|
||||
|
||||
eval( cmd, io_buffer, SUBST );
|
||||
if( eval( cmd, io_buffer, SUBST ) )
|
||||
{
|
||||
status = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = proc_get_last_status();
|
||||
}
|
||||
|
||||
io_buffer_read( io_buffer );
|
||||
|
||||
status = proc_get_last_status();
|
||||
proc_set_last_status( prev_status );
|
||||
|
||||
is_subshell = prev_subshell;
|
||||
|
|
7
expand.c
7
expand.c
|
@ -1265,7 +1265,12 @@ static int expand_cmdsubst( wchar_t *in, array_list_t *out )
|
|||
wcslcpy( subcmd, paran_begin+1, paran_end-paran_begin );
|
||||
subcmd[ paran_end-paran_begin-1]=0;
|
||||
|
||||
exec_subshell( subcmd, sub_res);
|
||||
if( exec_subshell( subcmd, sub_res) == -1 )
|
||||
{
|
||||
halloc_free( context );
|
||||
error( CMDSUBST_ERROR, -1, L"Unknown error while evaulating command substitution" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
tail_begin = paran_end + 1;
|
||||
if( *tail_begin == L'[' )
|
||||
|
|
1
input.c
1
input.c
|
@ -1297,6 +1297,7 @@ static void add_common_bindings()
|
|||
add_escaped_mapping( name[i], (L"\\C-y"), L"Control-y", L"yank" );
|
||||
add_mapping( name[i], L"", L"Any key", L"self-insert" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
12
kill.c
12
kill.c
|
@ -97,7 +97,13 @@ void kill_add( wchar_t *str )
|
|||
{
|
||||
wchar_t *escaped_str = escape( str, 1 );
|
||||
wchar_t *cmd = wcsdupcat2(L"echo ", escaped_str, L"|xsel -b",(void *)0);
|
||||
exec_subshell( cmd, 0 );
|
||||
if( exec_subshell( cmd, 0 ) == -1 )
|
||||
{
|
||||
/*
|
||||
Do nothing on failiure
|
||||
*/
|
||||
}
|
||||
|
||||
free( cut_buffer );
|
||||
free( cmd );
|
||||
|
||||
|
@ -192,7 +198,8 @@ static void kill_check_x_buffer()
|
|||
wchar_t *new_cut_buffer=0;
|
||||
array_list_t list;
|
||||
al_init( &list );
|
||||
exec_subshell( cmd, &list );
|
||||
if( exec_subshell( cmd, &list ) != -1 )
|
||||
{
|
||||
|
||||
for( i=0; i<al_get_count( &list ); i++ )
|
||||
{
|
||||
|
@ -237,6 +244,7 @@ static void kill_check_x_buffer()
|
|||
kill_add_internal( cut_buffer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
al_foreach( &list, &free );
|
||||
al_destroy( &list );
|
||||
|
|
|
@ -878,7 +878,13 @@ static int parse_util_load_internal( const wchar_t *cmd,
|
|||
/*
|
||||
Source the completion file for the specified completion
|
||||
*/
|
||||
exec_subshell( src_cmd, 0 );
|
||||
if( exec_subshell( src_cmd, 0 ) == -1 )
|
||||
{
|
||||
/*
|
||||
Do nothing on failiure
|
||||
*/
|
||||
}
|
||||
|
||||
free(src_cmd);
|
||||
reloaded = 1;
|
||||
}
|
||||
|
|
4
parser.c
4
parser.c
|
@ -2910,7 +2910,7 @@ int parser_test( const wchar_t * buff,
|
|||
*/
|
||||
if( contains_str( cmd,
|
||||
L"end",
|
||||
0 ) )
|
||||
(void *)0 ) )
|
||||
{
|
||||
err=1;
|
||||
if( out )
|
||||
|
@ -2985,7 +2985,7 @@ int parser_test( const wchar_t * buff,
|
|||
if( contains_str( cmd,
|
||||
L"or",
|
||||
L"and",
|
||||
0 ) )
|
||||
(void *)0 ) )
|
||||
{
|
||||
/*
|
||||
'or' and 'and' can not be used inside pipelines
|
||||
|
|
Loading…
Reference in a new issue