aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-04-06 18:42:11 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-04-06 18:42:11 +0000
commitab2b06434240bb11f5bef7201f9d01027df79896 (patch)
tree1d58f790899b2609676a3508b94cff3f385b9993
parent0e15138c03db5ac6b68ac24a074bf1c1532cbe1e (diff)
downloadbusybox-w32-ab2b06434240bb11f5bef7201f9d01027df79896.tar.gz
busybox-w32-ab2b06434240bb11f5bef7201f9d01027df79896.tar.bz2
busybox-w32-ab2b06434240bb11f5bef7201f9d01027df79896.zip
hush: s/last_return_code/last_exitcode/g
-rw-r--r--shell/hush.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/shell/hush.c b/shell/hush.c
index c563cfe33..14ca52ec0 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -481,7 +481,7 @@ struct globals {
481#endif 481#endif
482 smallint fake_mode; 482 smallint fake_mode;
483 /* These four support $?, $#, and $1 */ 483 /* These four support $?, $#, and $1 */
484 smalluint last_return_code; 484 smalluint last_exitcode;
485 /* are global_argv and global_argv[1..n] malloced? (note: not [0]) */ 485 /* are global_argv and global_argv[1..n] malloced? (note: not [0]) */
486 smalluint global_args_malloced; 486 smalluint global_args_malloced;
487 /* how many non-NULL argv's we have. NB: $# + 1 */ 487 /* how many non-NULL argv's we have. NB: $# + 1 */
@@ -876,10 +876,10 @@ static int check_and_run_traps(int sig)
876 if (G.traps[sig][0]) { 876 if (G.traps[sig][0]) {
877 /* We have user-defined handler */ 877 /* We have user-defined handler */
878 char *argv[] = { NULL, xstrdup(G.traps[sig]), NULL }; 878 char *argv[] = { NULL, xstrdup(G.traps[sig]), NULL };
879 save_rcode = G.last_return_code; 879 save_rcode = G.last_exitcode;
880 builtin_eval(argv); 880 builtin_eval(argv);
881 free(argv[1]); 881 free(argv[1]);
882 G.last_return_code = save_rcode; 882 G.last_exitcode = save_rcode;
883 } /* else: "" trap, ignoring signal */ 883 } /* else: "" trap, ignoring signal */
884 continue; 884 continue;
885 } 885 }
@@ -1700,7 +1700,7 @@ static int expand_vars_to_list(o_string *output, int n, char *arg, char or_mask)
1700 val = G.last_bg_pid ? utoa(G.last_bg_pid) : (char*)""; 1700 val = G.last_bg_pid ? utoa(G.last_bg_pid) : (char*)"";
1701 break; 1701 break;
1702 case '?': /* exitcode */ 1702 case '?': /* exitcode */
1703 val = utoa(G.last_return_code); 1703 val = utoa(G.last_exitcode);
1704 break; 1704 break;
1705 case '#': /* argc */ 1705 case '#': /* argc */
1706 if (arg[1] != SPECIAL_VAR_SYMBOL) 1706 if (arg[1] != SPECIAL_VAR_SYMBOL)
@@ -2313,7 +2313,7 @@ static void re_execute_shell(const char *s)
2313 sprintf(param_buf, "-$%x:%x:%x" USE_HUSH_LOOPS(":%x") 2313 sprintf(param_buf, "-$%x:%x:%x" USE_HUSH_LOOPS(":%x")
2314 , (unsigned) G.root_pid 2314 , (unsigned) G.root_pid
2315 , (unsigned) G.last_bg_pid 2315 , (unsigned) G.last_bg_pid
2316 , (unsigned) G.last_return_code 2316 , (unsigned) G.last_exitcode
2317 USE_HUSH_LOOPS(, G.depth_of_loop) 2317 USE_HUSH_LOOPS(, G.depth_of_loop)
2318 ); 2318 );
2319 /* 1:hush 2:-$<pid>:<pid>:<exitcode>:<depth> <vars...> 2319 /* 1:hush 2:-$<pid>:<pid>:<exitcode>:<depth> <vars...>
@@ -3125,7 +3125,7 @@ static int run_list(struct pipe *pi)
3125 last_rword = RES_XXXX; 3125 last_rword = RES_XXXX;
3126#endif 3126#endif
3127 last_followup = PIPE_SEQ; 3127 last_followup = PIPE_SEQ;
3128 rcode = G.last_return_code; 3128 rcode = G.last_exitcode;
3129 3129
3130 /* Go through list of pipes, (maybe) executing them. */ 3130 /* Go through list of pipes, (maybe) executing them. */
3131 for (; pi; pi = USE_HUSH_LOOPS(rword == RES_DONE ? loop_top : ) pi->next) { 3131 for (; pi; pi = USE_HUSH_LOOPS(rword == RES_DONE ? loop_top : ) pi->next) {
@@ -3162,7 +3162,7 @@ static int run_list(struct pipe *pi)
3162 if (cond_code) { 3162 if (cond_code) {
3163 if (rword == RES_THEN) { 3163 if (rword == RES_THEN) {
3164 /* if false; then ... fi has exitcode 0! */ 3164 /* if false; then ... fi has exitcode 0! */
3165 G.last_return_code = rcode = EXIT_SUCCESS; 3165 G.last_exitcode = rcode = EXIT_SUCCESS;
3166 /* "if <false> THEN cmd": skip cmd */ 3166 /* "if <false> THEN cmd": skip cmd */
3167 continue; 3167 continue;
3168 } 3168 }
@@ -3191,7 +3191,7 @@ static int run_list(struct pipe *pi)
3191 if (pi->next->res_word == RES_IN) { 3191 if (pi->next->res_word == RES_IN) {
3192 /* if no variable values after "in" we skip "for" */ 3192 /* if no variable values after "in" we skip "for" */
3193 if (!pi->next->cmds[0].argv) { 3193 if (!pi->next->cmds[0].argv) {
3194 G.last_return_code = rcode = EXIT_SUCCESS; 3194 G.last_exitcode = rcode = EXIT_SUCCESS;
3195 debug_printf_exec(": null FOR: exitcode EXIT_SUCCESS\n"); 3195 debug_printf_exec(": null FOR: exitcode EXIT_SUCCESS\n");
3196 break; 3196 break;
3197 } 3197 }
@@ -3280,7 +3280,7 @@ static int run_list(struct pipe *pi)
3280 if (r != -1) { 3280 if (r != -1) {
3281 /* We only ran a builtin: rcode is already known 3281 /* We only ran a builtin: rcode is already known
3282 * and we don't need to wait for anything. */ 3282 * and we don't need to wait for anything. */
3283 G.last_return_code = rcode; 3283 G.last_exitcode = rcode;
3284 debug_printf_exec(": builtin exitcode %d\n", rcode); 3284 debug_printf_exec(": builtin exitcode %d\n", rcode);
3285 check_and_run_traps(0); 3285 check_and_run_traps(0);
3286#if ENABLE_HUSH_LOOPS 3286#if ENABLE_HUSH_LOOPS
@@ -3312,7 +3312,7 @@ static int run_list(struct pipe *pi)
3312 if (G.run_list_level == 1) 3312 if (G.run_list_level == 1)
3313 insert_bg_job(pi); 3313 insert_bg_job(pi);
3314#endif 3314#endif
3315 G.last_return_code = rcode = EXIT_SUCCESS; 3315 G.last_exitcode = rcode = EXIT_SUCCESS;
3316 debug_printf_exec(": cmd&: exitcode EXIT_SUCCESS\n"); 3316 debug_printf_exec(": cmd&: exitcode EXIT_SUCCESS\n");
3317 } else { 3317 } else {
3318#if ENABLE_HUSH_JOB 3318#if ENABLE_HUSH_JOB
@@ -3328,7 +3328,7 @@ static int run_list(struct pipe *pi)
3328 debug_printf_exec(": checkjobs exitcode %d\n", rcode); 3328 debug_printf_exec(": checkjobs exitcode %d\n", rcode);
3329 check_and_run_traps(0); 3329 check_and_run_traps(0);
3330 } 3330 }
3331 G.last_return_code = rcode; 3331 G.last_exitcode = rcode;
3332 } 3332 }
3333 } 3333 }
3334 3334
@@ -3343,7 +3343,7 @@ static int run_list(struct pipe *pi)
3343 if (rword == RES_WHILE) { 3343 if (rword == RES_WHILE) {
3344 if (rcode) { 3344 if (rcode) {
3345 /* "while false; do...done" - exitcode 0 */ 3345 /* "while false; do...done" - exitcode 0 */
3346 G.last_return_code = rcode = EXIT_SUCCESS; 3346 G.last_exitcode = rcode = EXIT_SUCCESS;
3347 debug_printf_exec(": while expr is false: breaking (exitcode:EXIT_SUCCESS)\n"); 3347 debug_printf_exec(": while expr is false: breaking (exitcode:EXIT_SUCCESS)\n");
3348 goto check_jobs_and_break; 3348 goto check_jobs_and_break;
3349 } 3349 }
@@ -3922,7 +3922,7 @@ static FILE *generate_stream_from_string(const char *s)
3922#if BB_MMU 3922#if BB_MMU
3923 reset_traps_to_defaults(); 3923 reset_traps_to_defaults();
3924 parse_and_run_string(s); 3924 parse_and_run_string(s);
3925 _exit(G.last_return_code); 3925 _exit(G.last_exitcode);
3926#else 3926#else
3927 /* We re-execute after vfork on NOMMU. This makes this script safe: 3927 /* We re-execute after vfork on NOMMU. This makes this script safe:
3928 * yes "0123456789012345678901234567890" | dd bs=32 count=64k >BIG 3928 * yes "0123456789012345678901234567890" | dd bs=32 count=64k >BIG
@@ -5059,7 +5059,7 @@ int hush_main(int argc, char **argv)
5059 5059
5060 INIT_G(); 5060 INIT_G();
5061 if (EXIT_SUCCESS) /* if EXIT_SUCCESS == 0, is already done */ 5061 if (EXIT_SUCCESS) /* if EXIT_SUCCESS == 0, is already done */
5062 G.last_return_code = EXIT_SUCCESS; 5062 G.last_exitcode = EXIT_SUCCESS;
5063#if !BB_MMU 5063#if !BB_MMU
5064 G.argv0_for_re_execing = argv[0]; 5064 G.argv0_for_re_execing = argv[0];
5065#endif 5065#endif
@@ -5145,7 +5145,7 @@ int hush_main(int argc, char **argv)
5145 optarg++; 5145 optarg++;
5146 G.last_bg_pid = bb_strtou(optarg, &optarg, 16); 5146 G.last_bg_pid = bb_strtou(optarg, &optarg, 16);
5147 optarg++; 5147 optarg++;
5148 G.last_return_code = bb_strtou(optarg, &optarg, 16); 5148 G.last_exitcode = bb_strtou(optarg, &optarg, 16);
5149# if ENABLE_HUSH_LOOPS 5149# if ENABLE_HUSH_LOOPS
5150 optarg++; 5150 optarg++;
5151 G.depth_of_loop = bb_strtou(optarg, &optarg, 16); 5151 G.depth_of_loop = bb_strtou(optarg, &optarg, 16);
@@ -5338,7 +5338,7 @@ int hush_main(int argc, char **argv)
5338 free(tmp); 5338 free(tmp);
5339 } 5339 }
5340#endif 5340#endif
5341 hush_exit(G.last_return_code); 5341 hush_exit(G.last_exitcode);
5342} 5342}
5343 5343
5344 5344
@@ -5467,7 +5467,7 @@ static int builtin_eval(char **argv)
5467 */ 5467 */
5468 parse_and_run_string(str); 5468 parse_and_run_string(str);
5469 free(str); 5469 free(str);
5470 rcode = G.last_return_code; 5470 rcode = G.last_exitcode;
5471 } 5471 }
5472 return rcode; 5472 return rcode;
5473} 5473}
@@ -5512,7 +5512,7 @@ static int builtin_exit(char **argv)
5512// TODO: warn if we have background jobs: "There are stopped jobs" 5512// TODO: warn if we have background jobs: "There are stopped jobs"
5513// On second consecutive 'exit', exit anyway. 5513// On second consecutive 'exit', exit anyway.
5514 if (*++argv == NULL) 5514 if (*++argv == NULL)
5515 hush_exit(G.last_return_code); 5515 hush_exit(G.last_exitcode);
5516 /* mimic bash: exit 123abc == exit 255 + error msg */ 5516 /* mimic bash: exit 123abc == exit 255 + error msg */
5517 xfunc_error_retval = 255; 5517 xfunc_error_retval = 255;
5518 /* bash: exit -2 == exit 254, no error msg */ 5518 /* bash: exit -2 == exit 254, no error msg */
@@ -5798,7 +5798,7 @@ static int builtin_source(char **argv)
5798 * set G.global_argv=argv+1, recurse, and restore. */ 5798 * set G.global_argv=argv+1, recurse, and restore. */
5799 parse_and_run_file(input); 5799 parse_and_run_file(input);
5800 fclose(input); 5800 fclose(input);
5801 return G.last_return_code; 5801 return G.last_exitcode;
5802} 5802}
5803 5803
5804static int builtin_umask(char **argv) 5804static int builtin_umask(char **argv)