diff options
author | axel <axel@liljencrantz.se> | 2006-12-14 00:21:07 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2006-12-14 00:21:07 +1000 |
commit | 2b05bdfa94116b4f37d3fcc461ac2778959c8491 (patch) | |
tree | b77a021e9faccc52ba3be5cb648de154fa77b6b7 /builtin.c | |
parent | 6c8a559023cc7ba950ee9e55176f6fe3e6335c03 (diff) |
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
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 46 |
1 files changed, 9 insertions, 37 deletions
@@ -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 ); - } - - break; - } - - default: - { - for( i=woptind; i<argc; i++ ) - { - if( !function_exists( argv[i] ) ) - res++; - else - { - if( !query ) - { - functions_def( argv[i], sb_out ); - } - } + functions_def( argv[i], sb_out ); } - - break; - } + } } + return res; } |