diff --git a/complete.c b/complete.c index 69c7748f0..eb8e3ac6e 100644 --- a/complete.c +++ b/complete.c @@ -909,24 +909,26 @@ 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( al_get_count( &l )>0 ) + if( exec_subshell( cmd, &l ) != -1 ) { - wchar_t *ln = (wchar_t *)al_get(&l, 0 ); - if( wcscmp( ln, L"unknown" ) != 0 ) + + if( al_get_count( &l )>0 ) { - desc = wcsdup( ln); - /* - I have decided I prefer to have the description - begin in uppercase and the whole universe will just - have to accept it. Hah! - */ - desc[0]=towupper(desc[0]); + wchar_t *ln = (wchar_t *)al_get(&l, 0 ); + if( wcscmp( ln, L"unknown" ) != 0 ) + { + desc = wcsdup( ln); + /* + I have decided I prefer to have the description + begin in uppercase and the whole universe will just + have to accept it. Hah! + */ + desc[0]=towupper(desc[0]); + } } } - + + free(cmd); al_foreach( &l, &free ); al_destroy( &l ); } @@ -1155,79 +1157,82 @@ 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 - the result into a hashtable with the completion as key and the - description as value. - - Should be reasonably fast, since no memory allocations are needed. - */ - for( i=0; i