From 24fea5dd7b1232efba673f5984a57b21fce0934e Mon Sep 17 00:00:00 2001 From: axel Date: Thu, 14 Dec 2006 00:34:31 +1000 Subject: [PATCH] Code cleanup: Use a macro constant instead fo a literal for builtin exit codes darcs-hash:20061213143431-ac50b-5c5cec623ecca9f52c7d44cfcb26f07fe2fcda39.gz --- builtin.c | 82 +++++++++++++++++++++++++++---------------------------- proc.h | 7 ++++- 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/builtin.c b/builtin.c index 0a2bfde0d..7ffa6c9a8 100644 --- a/builtin.c +++ b/builtin.c @@ -427,7 +427,7 @@ static int builtin_bind( wchar_t **argv ) case 'h': builtin_print_help( argv[0], sb_out ); - return 0; + return STATUS_BUILTIN_OK; case '?': builtin_print_help( argv[0], sb_err ); @@ -443,7 +443,7 @@ static int builtin_bind( wchar_t **argv ) input_parse_inputrc_line( argv[i] ); } - return 0; + return STATUS_BUILTIN_OK; } /** @@ -517,7 +517,7 @@ static int builtin_block( wchar_t **argv ) return STATUS_BUILTIN_ERROR; case 'h': builtin_print_help( argv[0], sb_out ); - return 0; + return STATUS_BUILTIN_OK; case 'g': scope = GLOBAL; @@ -600,7 +600,7 @@ static int builtin_block( wchar_t **argv ) } } - return 0; + return STATUS_BUILTIN_OK; } @@ -658,7 +658,7 @@ static int builtin_builtin( wchar_t **argv ) return STATUS_BUILTIN_ERROR; case 'h': builtin_print_help( argv[0], sb_out ); - return 0; + return STATUS_BUILTIN_OK; case 'n': list=1; @@ -696,7 +696,7 @@ static int builtin_builtin( wchar_t **argv ) } al_destroy( &names ); } - return 0; + return STATUS_BUILTIN_OK; } /** @@ -748,7 +748,7 @@ static int builtin_generic( wchar_t **argv ) case 'h': builtin_print_help( argv[0], sb_out ); - return 0; + return STATUS_BUILTIN_OK; case '?': builtin_print_help( argv[0], sb_err ); @@ -857,7 +857,7 @@ static int builtin_functions( wchar_t **argv ) int argc=builtin_count_args( argv ); int list=0; int show_hidden=0; - int res = 0; + int res = STATUS_BUILTIN_OK; int query = 0; woptind=0; @@ -939,7 +939,7 @@ static int builtin_functions( wchar_t **argv ) case 'h': builtin_print_help( argv[0], sb_out ); - return 0; + return STATUS_BUILTIN_OK; case 'q': query = 1; @@ -973,7 +973,7 @@ static int builtin_functions( wchar_t **argv ) int i; for( i=woptind; itok_pos = parser_get_pos(); current_block->skip = 1; - return 0; + return STATUS_BUILTIN_OK; } @@ -1490,7 +1490,7 @@ static int builtin_random( wchar_t **argv ) return STATUS_BUILTIN_ERROR; } } - return 0; + return STATUS_BUILTIN_OK; } @@ -1600,7 +1600,7 @@ static int builtin_read( wchar_t **argv ) case 'h': builtin_print_help( argv[0], sb_out ); - return 0; + return STATUS_BUILTIN_OK; case L'?': builtin_print_help( argv[0], sb_err ); @@ -1791,7 +1791,7 @@ static int builtin_status( wchar_t **argv ) int mode = NORMAL; int argc = builtin_count_args( argv ); - int res=0; + int res=STATUS_BUILTIN_OK; woptind=0; @@ -1879,7 +1879,7 @@ static int builtin_status( wchar_t **argv ) case 'h': builtin_print_help( argv[0], sb_out ); - return 0; + return STATUS_BUILTIN_OK; case 'j': if( wcscmp( woptarg, L"full" ) == 0 ) @@ -2059,7 +2059,7 @@ static int set_pwd( wchar_t *env) if( !res ) { builtin_wperror( L"wgetcwd" ); - return 0; + return STATUS_BUILTIN_OK; } env_set( env, dir_path, ENV_EXPORT | ENV_GLOBAL ); return 1; @@ -2075,7 +2075,7 @@ static int builtin_cd( wchar_t **argv ) { wchar_t *dir_in; wchar_t *dir; - int res=0; + int res=STATUS_BUILTIN_OK; void *context = halloc( 0, 0 ); @@ -2143,7 +2143,7 @@ static int builtin_cd( wchar_t **argv ) static int builtin_source( wchar_t ** argv ) { int fd; - int res; + int res = STATUS_BUILTIN_OK; struct stat buf; int argc; @@ -2172,7 +2172,7 @@ static int builtin_source( wchar_t ** argv ) if( ( fd = wopen( argv[1], O_RDONLY ) ) == -1 ) { builtin_wperror( L"open" ); - res = 1; + res = STATUS_BUILTIN_ERROR; } else { @@ -2426,7 +2426,7 @@ static int send_to_bg( job_t *j, const wchar_t *name ) make_first( j ); job_set_flag( j, JOB_FOREGROUND, 0 ); job_continue( j, job_is_stopped(j) ); - return 0; + return STATUS_BUILTIN_OK; } @@ -2435,7 +2435,7 @@ static int send_to_bg( job_t *j, const wchar_t *name ) */ static int builtin_bg( wchar_t **argv ) { - int res = 0; + int res = STATUS_BUILTIN_OK; if( argv[1] == 0 ) { @@ -2478,7 +2478,7 @@ static int builtin_bg( wchar_t **argv ) static int builtin_for( wchar_t **argv ) { int argc = builtin_count_args( argv ); - int res=1; + int res=STATUS_BUILTIN_ERROR; if( argc < 3) @@ -2763,7 +2763,7 @@ static int builtin_break_continue( wchar_t **argv ) } b->skip=1; b->loop_status = is_break?LOOP_BREAK:LOOP_CONTINUE; - return 0; + return STATUS_BUILTIN_OK; } /** @@ -2838,7 +2838,7 @@ static int builtin_return( wchar_t **argv ) */ static int builtin_switch( wchar_t **argv ) { - int res=0; + int res=STATUS_BUILTIN_OK; int argc = builtin_count_args( argv ); if( argc != 2 ) @@ -2886,7 +2886,7 @@ static int builtin_case( wchar_t **argv ) if( current_block->param2.switch_taken ) { - return 0; + return STATUS_BUILTIN_OK; } for( i=1; i