diff options
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/shell/hush.c b/shell/hush.c index e20bf7a06..94b29c03d 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -110,7 +110,7 @@ | |||
110 | #include "busybox.h" | 110 | #include "busybox.h" |
111 | #include "cmdedit.h" | 111 | #include "cmdedit.h" |
112 | #else | 112 | #else |
113 | #define applet_name "hush" | 113 | #define bb_applet_name "hush" |
114 | #include "standalone.h" | 114 | #include "standalone.h" |
115 | #define hush_main main | 115 | #define hush_main main |
116 | #undef CONFIG_FEATURE_SH_FANCY_PROMPT | 116 | #undef CONFIG_FEATURE_SH_FANCY_PROMPT |
@@ -320,7 +320,7 @@ static inline void debug_printf(const char *format, ...) { } | |||
320 | #define final_printf debug_printf | 320 | #define final_printf debug_printf |
321 | 321 | ||
322 | static void __syntax(char *file, int line) { | 322 | static void __syntax(char *file, int line) { |
323 | error_msg("syntax error %s:%d", file, line); | 323 | bb_error_msg("syntax error %s:%d", file, line); |
324 | } | 324 | } |
325 | #define syntax() __syntax(__FILE__, __LINE__) | 325 | #define syntax() __syntax(__FILE__, __LINE__) |
326 | 326 | ||
@@ -441,11 +441,11 @@ static struct built_in_command bltins[] = { | |||
441 | 441 | ||
442 | static const char *set_cwd(void) | 442 | static const char *set_cwd(void) |
443 | { | 443 | { |
444 | if(cwd==unknown) | 444 | if(cwd==bb_msg_unknown) |
445 | cwd = NULL; /* xgetcwd(arg) called free(arg) */ | 445 | cwd = NULL; /* xgetcwd(arg) called free(arg) */ |
446 | cwd = xgetcwd((char *)cwd); | 446 | cwd = xgetcwd((char *)cwd); |
447 | if (!cwd) | 447 | if (!cwd) |
448 | cwd = unknown; | 448 | cwd = bb_msg_unknown; |
449 | return cwd; | 449 | return cwd; |
450 | } | 450 | } |
451 | 451 | ||
@@ -548,7 +548,7 @@ static int builtin_export(struct child_prog *child) | |||
548 | } | 548 | } |
549 | } | 549 | } |
550 | if (res<0) | 550 | if (res<0) |
551 | perror_msg("export"); | 551 | bb_perror_msg("export"); |
552 | else if(res==0) | 552 | else if(res==0) |
553 | res = set_local_var(name, 1); | 553 | res = set_local_var(name, 1); |
554 | else | 554 | else |
@@ -573,12 +573,12 @@ static int builtin_fg_bg(struct child_prog *child) | |||
573 | } | 573 | } |
574 | } | 574 | } |
575 | if (!pi) { | 575 | if (!pi) { |
576 | error_msg("%s: no current job", child->argv[0]); | 576 | bb_error_msg("%s: no current job", child->argv[0]); |
577 | return EXIT_FAILURE; | 577 | return EXIT_FAILURE; |
578 | } | 578 | } |
579 | } else { | 579 | } else { |
580 | if (sscanf(child->argv[1], "%%%d", &jobnum) != 1) { | 580 | if (sscanf(child->argv[1], "%%%d", &jobnum) != 1) { |
581 | error_msg("%s: bad argument '%s'", child->argv[0], child->argv[1]); | 581 | bb_error_msg("%s: bad argument '%s'", child->argv[0], child->argv[1]); |
582 | return EXIT_FAILURE; | 582 | return EXIT_FAILURE; |
583 | } | 583 | } |
584 | for (pi = job_list; pi; pi = pi->next) { | 584 | for (pi = job_list; pi; pi = pi->next) { |
@@ -587,7 +587,7 @@ static int builtin_fg_bg(struct child_prog *child) | |||
587 | } | 587 | } |
588 | } | 588 | } |
589 | if (!pi) { | 589 | if (!pi) { |
590 | error_msg("%s: %d: no such job", child->argv[0], jobnum); | 590 | bb_error_msg("%s: %d: no such job", child->argv[0], jobnum); |
591 | return EXIT_FAILURE; | 591 | return EXIT_FAILURE; |
592 | } | 592 | } |
593 | } | 593 | } |
@@ -605,7 +605,7 @@ static int builtin_fg_bg(struct child_prog *child) | |||
605 | if (i == ESRCH) { | 605 | if (i == ESRCH) { |
606 | remove_bg_job(pi); | 606 | remove_bg_job(pi); |
607 | } else { | 607 | } else { |
608 | perror_msg("kill (SIGCONT)"); | 608 | bb_perror_msg("kill (SIGCONT)"); |
609 | } | 609 | } |
610 | } | 610 | } |
611 | 611 | ||
@@ -728,7 +728,7 @@ static int builtin_source(struct child_prog *child) | |||
728 | /* XXX search through $PATH is missing */ | 728 | /* XXX search through $PATH is missing */ |
729 | input = fopen(child->argv[1], "r"); | 729 | input = fopen(child->argv[1], "r"); |
730 | if (!input) { | 730 | if (!input) { |
731 | error_msg("Couldn't open file '%s'", child->argv[1]); | 731 | bb_error_msg("Couldn't open file '%s'", child->argv[1]); |
732 | return EXIT_FAILURE; | 732 | return EXIT_FAILURE; |
733 | } | 733 | } |
734 | 734 | ||
@@ -996,7 +996,7 @@ static void mark_closed(int fd) | |||
996 | { | 996 | { |
997 | struct close_me *tmp; | 997 | struct close_me *tmp; |
998 | if (close_me_head == NULL || close_me_head->fd != fd) | 998 | if (close_me_head == NULL || close_me_head->fd != fd) |
999 | error_msg_and_die("corrupt close_me"); | 999 | bb_error_msg_and_die("corrupt close_me"); |
1000 | tmp = close_me_head; | 1000 | tmp = close_me_head; |
1001 | close_me_head = close_me_head->next; | 1001 | close_me_head = close_me_head->next; |
1002 | free(tmp); | 1002 | free(tmp); |
@@ -1029,7 +1029,7 @@ static int setup_redirects(struct child_prog *prog, int squirrel[]) | |||
1029 | if (openfd < 0) { | 1029 | if (openfd < 0) { |
1030 | /* this could get lost if stderr has been redirected, but | 1030 | /* this could get lost if stderr has been redirected, but |
1031 | bash and ash both lose it as well (though zsh doesn't!) */ | 1031 | bash and ash both lose it as well (though zsh doesn't!) */ |
1032 | perror_msg("error opening %s", redir->word.gl_pathv[0]); | 1032 | bb_perror_msg("error opening %s", redir->word.gl_pathv[0]); |
1033 | return 1; | 1033 | return 1; |
1034 | } | 1034 | } |
1035 | } else { | 1035 | } else { |
@@ -1125,14 +1125,14 @@ static void pseudo_exec(struct child_prog *child) | |||
1125 | #ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN | 1125 | #ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN |
1126 | /* Following discussions from November 2000 on the busybox mailing | 1126 | /* Following discussions from November 2000 on the busybox mailing |
1127 | * list, the default configuration, (without | 1127 | * list, the default configuration, (without |
1128 | * get_last_path_component()) lets the user force use of an | 1128 | * bb_get_last_path_component()) lets the user force use of an |
1129 | * external command by specifying the full (with slashes) filename. | 1129 | * external command by specifying the full (with slashes) filename. |
1130 | * If you enable CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN, then applets | 1130 | * If you enable CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN, then applets |
1131 | * _aways_ override external commands, so if you want to run | 1131 | * _aways_ override external commands, so if you want to run |
1132 | * /bin/cat, it will use BusyBox cat even if /bin/cat exists on the | 1132 | * /bin/cat, it will use BusyBox cat even if /bin/cat exists on the |
1133 | * filesystem and is _not_ busybox. Some systems may want this, | 1133 | * filesystem and is _not_ busybox. Some systems may want this, |
1134 | * most do not. */ | 1134 | * most do not. */ |
1135 | name = get_last_path_component(name); | 1135 | name = bb_get_last_path_component(name); |
1136 | #endif | 1136 | #endif |
1137 | /* Count argc for use in a second... */ | 1137 | /* Count argc for use in a second... */ |
1138 | for(argc_l=0;*argv_l!=NULL; argv_l++, argc_l++); | 1138 | for(argc_l=0;*argv_l!=NULL; argv_l++, argc_l++); |
@@ -1143,7 +1143,7 @@ static void pseudo_exec(struct child_prog *child) | |||
1143 | #endif | 1143 | #endif |
1144 | debug_printf("exec of %s\n",child->argv[0]); | 1144 | debug_printf("exec of %s\n",child->argv[0]); |
1145 | execvp(child->argv[0],child->argv); | 1145 | execvp(child->argv[0],child->argv); |
1146 | perror_msg("couldn't exec: %s",child->argv[0]); | 1146 | bb_perror_msg("couldn't exec: %s",child->argv[0]); |
1147 | _exit(1); | 1147 | _exit(1); |
1148 | } else if (child->group) { | 1148 | } else if (child->group) { |
1149 | debug_printf("runtime nesting to group\n"); | 1149 | debug_printf("runtime nesting to group\n"); |
@@ -1292,11 +1292,11 @@ static int checkjobs(struct pipe* fg_pipe) | |||
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | if (childpid == -1 && errno != ECHILD) | 1294 | if (childpid == -1 && errno != ECHILD) |
1295 | perror_msg("waitpid"); | 1295 | bb_perror_msg("waitpid"); |
1296 | 1296 | ||
1297 | /* move the shell to the foreground */ | 1297 | /* move the shell to the foreground */ |
1298 | //if (interactive && tcsetpgrp(shell_terminal, getpgid(0))) | 1298 | //if (interactive && tcsetpgrp(shell_terminal, getpgid(0))) |
1299 | // perror_msg("tcsetpgrp-2"); | 1299 | // bb_perror_msg("tcsetpgrp-2"); |
1300 | return -1; | 1300 | return -1; |
1301 | } | 1301 | } |
1302 | 1302 | ||
@@ -1381,7 +1381,7 @@ static int run_pipe_real(struct pipe *pi) | |||
1381 | * variable. */ | 1381 | * variable. */ |
1382 | int export_me=0; | 1382 | int export_me=0; |
1383 | char *name, *value; | 1383 | char *name, *value; |
1384 | name = xstrdup(child->argv[i]); | 1384 | name = bb_xstrdup(child->argv[i]); |
1385 | debug_printf("Local environment set: %s\n", name); | 1385 | debug_printf("Local environment set: %s\n", name); |
1386 | value = strchr(name, '='); | 1386 | value = strchr(name, '='); |
1387 | if (value) | 1387 | if (value) |
@@ -1441,7 +1441,7 @@ static int run_pipe_real(struct pipe *pi) | |||
1441 | 1441 | ||
1442 | /* pipes are inserted between pairs of commands */ | 1442 | /* pipes are inserted between pairs of commands */ |
1443 | if ((i + 1) < pi->num_progs) { | 1443 | if ((i + 1) < pi->num_progs) { |
1444 | if (pipe(pipefds)<0) perror_msg_and_die("pipe"); | 1444 | if (pipe(pipefds)<0) bb_perror_msg_and_die("pipe"); |
1445 | nextout = pipefds[1]; | 1445 | nextout = pipefds[1]; |
1446 | } else { | 1446 | } else { |
1447 | nextout=1; | 1447 | nextout=1; |
@@ -1626,11 +1626,11 @@ static int run_list_real(struct pipe *pi) | |||
1626 | if (interactive) { | 1626 | if (interactive) { |
1627 | /* move the new process group into the foreground */ | 1627 | /* move the new process group into the foreground */ |
1628 | if (tcsetpgrp(shell_terminal, pi->pgrp) && errno != ENOTTY) | 1628 | if (tcsetpgrp(shell_terminal, pi->pgrp) && errno != ENOTTY) |
1629 | perror_msg("tcsetpgrp-3"); | 1629 | bb_perror_msg("tcsetpgrp-3"); |
1630 | rcode = checkjobs(pi); | 1630 | rcode = checkjobs(pi); |
1631 | /* move the shell to the foreground */ | 1631 | /* move the shell to the foreground */ |
1632 | if (tcsetpgrp(shell_terminal, getpgid(0)) && errno != ENOTTY) | 1632 | if (tcsetpgrp(shell_terminal, getpgid(0)) && errno != ENOTTY) |
1633 | perror_msg("tcsetpgrp-4"); | 1633 | bb_perror_msg("tcsetpgrp-4"); |
1634 | } else { | 1634 | } else { |
1635 | rcode = checkjobs(pi); | 1635 | rcode = checkjobs(pi); |
1636 | } | 1636 | } |
@@ -1825,9 +1825,9 @@ static int xglob(o_string *dest, int flags, glob_t *pglob) | |||
1825 | debug_printf("globhack returned %d\n",gr); | 1825 | debug_printf("globhack returned %d\n",gr); |
1826 | } | 1826 | } |
1827 | if (gr == GLOB_NOSPACE) | 1827 | if (gr == GLOB_NOSPACE) |
1828 | error_msg_and_die("out of memory during glob"); | 1828 | bb_error_msg_and_die("out of memory during glob"); |
1829 | if (gr != 0) { /* GLOB_ABORTED ? */ | 1829 | if (gr != 0) { /* GLOB_ABORTED ? */ |
1830 | error_msg("glob(3) error %d",gr); | 1830 | bb_error_msg("glob(3) error %d",gr); |
1831 | } | 1831 | } |
1832 | /* globprint(glob_target); */ | 1832 | /* globprint(glob_target); */ |
1833 | return gr; | 1833 | return gr; |
@@ -1881,7 +1881,7 @@ static int set_local_var(const char *s, int flg_export) | |||
1881 | result++; | 1881 | result++; |
1882 | } else { | 1882 | } else { |
1883 | if(cur->flg_read_only) { | 1883 | if(cur->flg_read_only) { |
1884 | error_msg("%s: readonly variable", name); | 1884 | bb_error_msg("%s: readonly variable", name); |
1885 | result = -1; | 1885 | result = -1; |
1886 | } else { | 1886 | } else { |
1887 | if(flg_export>0 || cur->flg_export>1) | 1887 | if(flg_export>0 || cur->flg_export>1) |
@@ -1935,7 +1935,7 @@ static void unset_local_var(const char *name) | |||
1935 | if(cur!=0) { | 1935 | if(cur!=0) { |
1936 | struct variables *next = top_vars; | 1936 | struct variables *next = top_vars; |
1937 | if(cur->flg_read_only) { | 1937 | if(cur->flg_read_only) { |
1938 | error_msg("%s: readonly variable", name); | 1938 | bb_error_msg("%s: readonly variable", name); |
1939 | return; | 1939 | return; |
1940 | } else { | 1940 | } else { |
1941 | if(cur->flg_export) | 1941 | if(cur->flg_export) |
@@ -2139,7 +2139,7 @@ static int done_word(o_string *dest, struct p_context *ctx) | |||
2139 | if (ctx->pending_redirect) { | 2139 | if (ctx->pending_redirect) { |
2140 | ctx->pending_redirect=NULL; | 2140 | ctx->pending_redirect=NULL; |
2141 | if (glob_target->gl_pathc != 1) { | 2141 | if (glob_target->gl_pathc != 1) { |
2142 | error_msg("ambiguous redirect"); | 2142 | bb_error_msg("ambiguous redirect"); |
2143 | return 1; | 2143 | return 1; |
2144 | } | 2144 | } |
2145 | } else { | 2145 | } else { |
@@ -2231,7 +2231,7 @@ static int redirect_dup_num(struct in_str *input) | |||
2231 | } | 2231 | } |
2232 | if (ok) return d; | 2232 | if (ok) return d; |
2233 | 2233 | ||
2234 | error_msg("ambiguous redirect"); | 2234 | bb_error_msg("ambiguous redirect"); |
2235 | return -2; | 2235 | return -2; |
2236 | } | 2236 | } |
2237 | 2237 | ||
@@ -2267,14 +2267,14 @@ FILE *generate_stream_from_list(struct pipe *head) | |||
2267 | FILE *pf; | 2267 | FILE *pf; |
2268 | #if 1 | 2268 | #if 1 |
2269 | int pid, channel[2]; | 2269 | int pid, channel[2]; |
2270 | if (pipe(channel)<0) perror_msg_and_die("pipe"); | 2270 | if (pipe(channel)<0) bb_perror_msg_and_die("pipe"); |
2271 | #if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__) | 2271 | #if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__) |
2272 | pid=fork(); | 2272 | pid=fork(); |
2273 | #else | 2273 | #else |
2274 | pid=vfork(); | 2274 | pid=vfork(); |
2275 | #endif | 2275 | #endif |
2276 | if (pid<0) { | 2276 | if (pid<0) { |
2277 | perror_msg_and_die("fork"); | 2277 | bb_perror_msg_and_die("fork"); |
2278 | } else if (pid==0) { | 2278 | } else if (pid==0) { |
2279 | close(channel[0]); | 2279 | close(channel[0]); |
2280 | if (channel[1] != 1) { | 2280 | if (channel[1] != 1) { |
@@ -2450,7 +2450,7 @@ static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *i | |||
2450 | case '-': | 2450 | case '-': |
2451 | case '_': | 2451 | case '_': |
2452 | /* still unhandled, but should be eventually */ | 2452 | /* still unhandled, but should be eventually */ |
2453 | error_msg("unhandled syntax: $%c",ch); | 2453 | bb_error_msg("unhandled syntax: $%c",ch); |
2454 | return 1; | 2454 | return 1; |
2455 | break; | 2455 | break; |
2456 | default: | 2456 | default: |
@@ -2811,7 +2811,7 @@ int hush_main(int argc, char **argv) | |||
2811 | " or: sh -c command [args]...\n\n"); | 2811 | " or: sh -c command [args]...\n\n"); |
2812 | exit(EXIT_FAILURE); | 2812 | exit(EXIT_FAILURE); |
2813 | #else | 2813 | #else |
2814 | show_usage(); | 2814 | bb_show_usage(); |
2815 | #endif | 2815 | #endif |
2816 | } | 2816 | } |
2817 | } | 2817 | } |
@@ -2845,12 +2845,12 @@ int hush_main(int argc, char **argv) | |||
2845 | debug_printf("\nrunning script '%s'\n", argv[optind]); | 2845 | debug_printf("\nrunning script '%s'\n", argv[optind]); |
2846 | global_argv = argv+optind; | 2846 | global_argv = argv+optind; |
2847 | global_argc = argc-optind; | 2847 | global_argc = argc-optind; |
2848 | input = xfopen(argv[optind], "r"); | 2848 | input = bb_xfopen(argv[optind], "r"); |
2849 | opt = parse_file_outer(input); | 2849 | opt = parse_file_outer(input); |
2850 | 2850 | ||
2851 | #ifdef CONFIG_FEATURE_CLEAN_UP | 2851 | #ifdef CONFIG_FEATURE_CLEAN_UP |
2852 | fclose(input); | 2852 | fclose(input); |
2853 | if (cwd && cwd != unknown) | 2853 | if (cwd && cwd != bb_msg_unknown) |
2854 | free((char*)cwd); | 2854 | free((char*)cwd); |
2855 | { | 2855 | { |
2856 | struct variables *cur, *tmp; | 2856 | struct variables *cur, *tmp; |