mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 08:51:14 -03:00
Make the functions builtin display function listing on -n to a terminal in a human-friendly format
darcs-hash:20060115115805-ac50b-fc5b468c0e68904e5cf934f43066ecfdf23e2a3b.gz
This commit is contained in:
32
builtin.c
32
builtin.c
@@ -876,6 +876,8 @@ static int builtin_functions( wchar_t **argv )
|
||||
}
|
||||
else if( list )
|
||||
{
|
||||
int is_screen = !builtin_out_redirect && isatty(1);
|
||||
|
||||
al_init( &names );
|
||||
function_get_names( &names, show_hidden );
|
||||
names_arr = list_to_char_arr( &names );
|
||||
@@ -883,13 +885,33 @@ static int builtin_functions( wchar_t **argv )
|
||||
al_get_count( &names ),
|
||||
sizeof(wchar_t *),
|
||||
(int (*)(const void *, const void *))&wcsfilecmp );
|
||||
for( i=0; i<al_get_count( &names ); i++ )
|
||||
if( is_screen )
|
||||
{
|
||||
sb_append2( sb_out,
|
||||
names_arr[i],
|
||||
L"\n",
|
||||
(void *)0 );
|
||||
string_buffer_t buff;
|
||||
sb_init( &buff );
|
||||
|
||||
for( i=0; i<al_get_count( &names ); i++ )
|
||||
{
|
||||
sb_append2( &buff,
|
||||
names_arr[i],
|
||||
L", ",
|
||||
(void *)0 );
|
||||
}
|
||||
|
||||
write_screen( (wchar_t *)buff.buff );
|
||||
sb_destroy( &buff );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i=0; i<al_get_count( &names ); i++ )
|
||||
{
|
||||
sb_append2( sb_out,
|
||||
names_arr[i],
|
||||
L"\n",
|
||||
(void *)0 );
|
||||
}
|
||||
}
|
||||
|
||||
free( names_arr );
|
||||
al_destroy( &names );
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user