Update functions builtin so that default behaviour when not given any arguments is to print only names of all existing functions, not their definitions. Use 'functions (functions)' to get the latter.

darcs-hash:20061213142107-ac50b-16d0a9097ede4b0cd49847618d65fcbfee699393.gz
This commit is contained in:
axel 2006-12-14 00:21:07 +10:00
parent 6c8a559023
commit 2b05bdfa94

View File

@ -957,13 +957,12 @@ static int builtin_functions( wchar_t **argv )
/*
Erase, desc, query and list are mutually exclusive
*/
if( (erase + (desc!=0) + list + query) > 1 )
if( (erase + (!!desc) + list + query) > 1 )
{
sb_printf( sb_err,
_( L"%ls: Invalid combination of options\n" ),
argv[0] );
builtin_print_help( argv[0], sb_err );
return STATUS_BUILTIN_ERROR;
@ -1006,7 +1005,7 @@ static int builtin_functions( wchar_t **argv )
return 0;
}
else if( list )
else if( list || (argc==woptind))
{
int is_screen = !builtin_out_redirect && isatty(1);
@ -1044,46 +1043,19 @@ static int builtin_functions( wchar_t **argv )
return 0;
}
switch( argc - woptind )
for( i=woptind; i<argc; i++ )
{
case 0:
if( !function_exists( argv[i] ) )
res++;
else
{
if( !query )
{
sb_append( sb_out, _( L"Current function definitions are:\n\n" ) );
al_init( &names );
function_get_names( &names, show_hidden );
sort_list( &names );
for( i=0; i<al_get_count( &names ); i++ )
{
functions_def( (wchar_t *)al_get( &names, i ), sb_out );
}
al_destroy( &names );
functions_def( argv[i], sb_out );
}
break;
}
default:
{
for( i=woptind; i<argc; i++ )
{
if( !function_exists( argv[i] ) )
res++;
else
{
if( !query )
{
functions_def( argv[i], sb_out );
}
}
}
break;
}
}
return res;
}