diff options
author | axel <axel@liljencrantz.se> | 2005-12-04 02:43:56 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2005-12-04 02:43:56 +1000 |
commit | 9b4c34aa4c95a8d2c6703b7c04443f82f086d359 (patch) | |
tree | 5ce8bb90b506499cf511c1d84d356d91b6131b7b /complete.c | |
parent | e2ebc0e443d773fc0bc2cb0958bc3cf721717969 (diff) |
Use csh-style error rules with wildcards, i.e. if no matches are found, the command is not executed
darcs-hash:20051203164356-ac50b-1b1818db2698eab9ae765a5af1e259bce3ab37e7.gz
Diffstat (limited to 'complete.c')
-rw-r--r-- | complete.c | 53 |
1 files changed, 29 insertions, 24 deletions
@@ -1213,10 +1213,12 @@ static void complete_cmd( const wchar_t *cmd, array_list_t tmp; al_init( &tmp ); - expand_string( wcsdup(cmd), - comp, - ACCEPT_INCOMPLETE | EXECUTABLES_ONLY ); - complete_cmd_desc( cmd, comp ); + if( expand_string( wcsdup(cmd), + comp, + ACCEPT_INCOMPLETE | EXECUTABLES_ONLY ) != EXPAND_ERROR ) + { + complete_cmd_desc( cmd, comp ); + } al_destroy( &tmp ); } else @@ -1237,14 +1239,15 @@ static void complete_cmd( const wchar_t *cmd, al_init( &tmp ); - expand_string( nxt_completion, + if( expand_string( nxt_completion, &tmp, ACCEPT_INCOMPLETE | - EXECUTABLES_ONLY ); - - for( i=0; i<al_get_count(&tmp); i++ ) + EXECUTABLES_ONLY ) != EXPAND_ERROR ) { - al_push( comp, al_get( &tmp, i ) ); + for( i=0; i<al_get_count(&tmp); i++ ) + { + al_push( comp, al_get( &tmp, i ) ); + } } al_destroy( &tmp ); @@ -1290,24 +1293,26 @@ static void complete_cmd( const wchar_t *cmd, al_init( &tmp ); - expand_string( nxt_completion, + if( expand_string( nxt_completion, &tmp, - ACCEPT_INCOMPLETE | DIRECTORIES_ONLY ); - - for( i=0; i<al_get_count(&tmp); i++ ) + ACCEPT_INCOMPLETE | DIRECTORIES_ONLY ) != EXPAND_ERROR ) { - wchar_t *nxt = (wchar_t *)al_get( &tmp, i ); - - wchar_t *desc = wcsrchr( nxt, COMPLETE_SEP ); - int is_valid = (desc && (wcscmp(desc, - COMPLETE_DIRECTORY_DESC)==0)); - if( is_valid ) - { - al_push( comp, nxt ); - } - else + + for( i=0; i<al_get_count(&tmp); i++ ) { - free(nxt); + wchar_t *nxt = (wchar_t *)al_get( &tmp, i ); + + wchar_t *desc = wcsrchr( nxt, COMPLETE_SEP ); + int is_valid = (desc && (wcscmp(desc, + COMPLETE_DIRECTORY_DESC)==0)); + if( is_valid ) + { + al_push( comp, nxt ); + } + else + { + free(nxt); + } } } |