diff --git a/complete.c b/complete.c index cc842d068..e491facfb 100644 --- a/complete.c +++ b/complete.c @@ -202,29 +202,6 @@ void completion_allocate( array_list_t *context, al_push( context, res ); } -void completion_allocate2( array_list_t *context, - wchar_t *comp, - wchar_t sep ) -{ - completion_t *res = halloc( context, sizeof( completion_t) ); - wchar_t *sep_pos = wcschr( comp, sep ); - int flags = 0; - - if( sep_pos ) - { - *sep_pos = 0; - res->description = halloc_wcsdup( context, sep_pos+1 ); - } - - res->completion = halloc_wcsdup( context, comp ); - - if( ( wcslen(comp) > 0 ) && ( wcschr( L"/=@:", comp[wcslen(comp)-1] ) != 0 ) ) - flags |= COMPLETE_NO_SPACE; - res->flags = flags; - al_push( context, res ); -} - - /** Destroys various structures used for tab-completion and free()s the memory used by them. */ diff --git a/complete.h b/complete.h index 57a0e3d3e..56e668846 100644 --- a/complete.h +++ b/complete.h @@ -247,15 +247,4 @@ void completion_allocate( array_list_t *context, int flags ); -/** - Create a new completion entry from an existing text entry - - \param context The halloc context to use for allocating new memory - \param comp the completion and possibly the description for it - \param sep the separator character between completion and description -*/ -void completion_allocate2( array_list_t *context, - wchar_t *comp, - wchar_t sep ); - #endif diff --git a/configure.ac b/configure.ac index 7e1a8cdf5..917a28ae5 100644 --- a/configure.ac +++ b/configure.ac @@ -246,7 +246,7 @@ AC_CACHE_VAL( ) # -# Try to enale large file support. This will make sure that on systems +# Try to enable large file support. This will make sure that on systems # where off_t can be either 32 or 64 bit, the latter size is used. On # other systems, this should do nothing. (Hopefully) # diff --git a/doc_src/commandline.txt b/doc_src/commandline.txt index 6fc7dea93..0202bbb34 100644 --- a/doc_src/commandline.txt +++ b/doc_src/commandline.txt @@ -7,7 +7,9 @@ - \c CMD is the new value of the commandline. If unspecified, the - current value of the commandline is written to standard output. + current value of the commandline is written to standard output. All + output from the commandline builtin is escaped, i.e. quotes are + removed, backslash escapes are expanded, etc.. The following switches change what the commandline builtin does diff --git a/wildcard.c b/wildcard.c index d80d47e30..85185b11a 100644 --- a/wildcard.c +++ b/wildcard.c @@ -511,9 +511,27 @@ static const wchar_t *file_get_desc( const wchar_t *filename, { return COMPLETE_DIRECTORY_SYMLINK_DESC; } - else if( waccess( filename, X_OK ) == 0 ) + else { - return COMPLETE_EXEC_LINK_DESC; + + if( ( buf.st_mode & S_IXUSR ) || + ( buf.st_mode & S_IXGRP ) || + ( buf.st_mode & S_IXOTH ) ) + { + + if( waccess( filename, X_OK ) == 0 ) + { + /* + Weird group permissions and other such + issues make it non-trivial to find out + if we can actually execute a file using + the result from stat. It is much safer + to use the access function, since it + tells us exactly what we want to know. + */ + return COMPLETE_EXEC_LINK_DESC; + } + } } return COMPLETE_SYMLINK_DESC; @@ -560,9 +578,26 @@ static const wchar_t *file_get_desc( const wchar_t *filename, { return COMPLETE_DIRECTORY_DESC; } - else if( waccess( filename, X_OK ) == 0 ) + else { - return COMPLETE_EXEC_DESC; + if( ( buf.st_mode & S_IXUSR ) || + ( buf.st_mode & S_IXGRP ) || + ( buf.st_mode & S_IXOTH ) ) + { + + if( waccess( filename, X_OK ) == 0 ) + { + /* + Weird group permissions and other such issues + make it non-trivial to find out if we can + actually execute a file using the result from + stat. It is much safer to use the access + function, since it tells us exactly what we want + to know. + */ + return COMPLETE_EXEC_DESC; + } + } } } @@ -590,9 +625,9 @@ static const wchar_t *file_get_desc( const wchar_t *filename, \param is_cmd whether we are performing command completion */ static void wildcard_completion_allocate( array_list_t *list, - wchar_t *fullname, - wchar_t *completion, - wchar_t *wc, + const wchar_t *fullname, + const wchar_t *completion, + const wchar_t *wc, int is_cmd ) { const wchar_t *desc; @@ -717,7 +752,7 @@ static void wildcard_completion_allocate( array_list_t *list, wildcard_complete( completion, wc, (wchar_t *)sb->buff, 0, list, flags ); if( free_completion ) - free( completion ); + free( (void *)completion ); } /**