diff options
author | mjn3 <mjn3@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-03-19 09:13:01 +0000 |
---|---|---|
committer | mjn3 <mjn3@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-03-19 09:13:01 +0000 |
commit | e901c15d890dbbdce4c086963cb1513653fc46b5 (patch) | |
tree | a318d0f03aa076c74b576ea45dc543a5669e8e91 /shell | |
parent | 40758c00616c3b2c85d83eb4afdeb04b1f65c9f1 (diff) | |
download | busybox-w32-e901c15d890dbbdce4c086963cb1513653fc46b5.tar.gz busybox-w32-e901c15d890dbbdce4c086963cb1513653fc46b5.tar.bz2 busybox-w32-e901c15d890dbbdce4c086963cb1513653fc46b5.zip |
Major coreutils update.
git-svn-id: svn://busybox.net/trunk/busybox@6751 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 32 | ||||
-rw-r--r-- | shell/cmdedit.c | 25 | ||||
-rw-r--r-- | shell/hush.c | 66 | ||||
-rw-r--r-- | shell/lash.c | 70 | ||||
-rw-r--r-- | shell/msh.c | 6 |
5 files changed, 99 insertions, 100 deletions
diff --git a/shell/ash.c b/shell/ash.c index 828a88872..fb65c2da0 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -1329,13 +1329,13 @@ static void setalias(char *name, char *val) | |||
1329 | if (!(ap->flag & ALIASINUSE)) { | 1329 | if (!(ap->flag & ALIASINUSE)) { |
1330 | free(ap->val); | 1330 | free(ap->val); |
1331 | } | 1331 | } |
1332 | ap->val = xstrdup(val); | 1332 | ap->val = bb_xstrdup(val); |
1333 | ap->flag &= ~ALIASDEAD; | 1333 | ap->flag &= ~ALIASDEAD; |
1334 | } else { | 1334 | } else { |
1335 | /* not found */ | 1335 | /* not found */ |
1336 | ap = xmalloc(sizeof(struct alias)); | 1336 | ap = xmalloc(sizeof(struct alias)); |
1337 | ap->name = xstrdup(name); | 1337 | ap->name = bb_xstrdup(name); |
1338 | ap->val = xstrdup(val); | 1338 | ap->val = bb_xstrdup(val); |
1339 | ap->flag = 0; | 1339 | ap->flag = 0; |
1340 | ap->next = 0; | 1340 | ap->next = 0; |
1341 | *app = ap; | 1341 | *app = ap; |
@@ -1829,7 +1829,7 @@ static void setpwd(const char *val, int setold) | |||
1829 | if (!val) | 1829 | if (!val) |
1830 | getpwd(); | 1830 | getpwd(); |
1831 | else | 1831 | else |
1832 | curdir = simplify_path(val); | 1832 | curdir = bb_simplify_path(val); |
1833 | if (cated) | 1833 | if (cated) |
1834 | free(cated); | 1834 | free(cated); |
1835 | INTON; | 1835 | INTON; |
@@ -3285,7 +3285,7 @@ static void tryexec(char *cmd, char **argv, char **envp) | |||
3285 | char *name = cmd; | 3285 | char *name = cmd; |
3286 | 3286 | ||
3287 | #ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN | 3287 | #ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN |
3288 | name = get_last_path_component(name); | 3288 | name = bb_get_last_path_component(name); |
3289 | if(find_applet_by_name(name) != NULL) | 3289 | if(find_applet_by_name(name) != NULL) |
3290 | flg_bb = 1; | 3290 | flg_bb = 1; |
3291 | #else | 3291 | #else |
@@ -7552,7 +7552,7 @@ static int dotcmd(int argc, char **argv) | |||
7552 | exitstatus = 0; | 7552 | exitstatus = 0; |
7553 | 7553 | ||
7554 | for (sp = cmdenviron; sp; sp = sp->next) | 7554 | for (sp = cmdenviron; sp; sp = sp->next) |
7555 | setvareq(xstrdup(sp->text), VSTRFIXED | VTEXTFIXED); | 7555 | setvareq(bb_xstrdup(sp->text), VSTRFIXED | VTEXTFIXED); |
7556 | 7556 | ||
7557 | if (argc >= 2) { /* That's what SVR2 does */ | 7557 | if (argc >= 2) { /* That's what SVR2 does */ |
7558 | char *fullname; | 7558 | char *fullname; |
@@ -7950,7 +7950,7 @@ static int umaskcmd(int argc, char **argv) | |||
7950 | umask(mask); | 7950 | umask(mask); |
7951 | } else { | 7951 | } else { |
7952 | mask = ~mask & 0777; | 7952 | mask = ~mask & 0777; |
7953 | if (!parse_mode(ap, &mask)) { | 7953 | if (!bb_parse_mode(ap, &mask)) { |
7954 | error("Illegal mode: %s", ap); | 7954 | error("Illegal mode: %s", ap); |
7955 | } | 7955 | } |
7956 | umask(~mask & 0777); | 7956 | umask(~mask & 0777); |
@@ -8795,7 +8795,7 @@ static void setparam(char **argv) | |||
8795 | for (nparam = 0; argv[nparam]; nparam++); | 8795 | for (nparam = 0; argv[nparam]; nparam++); |
8796 | ap = newparam = xmalloc((nparam + 1) * sizeof *ap); | 8796 | ap = newparam = xmalloc((nparam + 1) * sizeof *ap); |
8797 | while (*argv) { | 8797 | while (*argv) { |
8798 | *ap++ = xstrdup(*argv++); | 8798 | *ap++ = bb_xstrdup(*argv++); |
8799 | } | 8799 | } |
8800 | *ap = NULL; | 8800 | *ap = NULL; |
8801 | freeparam(&shellparam); | 8801 | freeparam(&shellparam); |
@@ -11429,7 +11429,7 @@ static void opentrace() | |||
11429 | #else | 11429 | #else |
11430 | strcpy(s, "./trace"); | 11430 | strcpy(s, "./trace"); |
11431 | #endif /* not_this_way */ | 11431 | #endif /* not_this_way */ |
11432 | if ((tracefile = wfopen(s, "a")) == NULL) | 11432 | if ((tracefile = bb_wfopen(s, "a")) == NULL) |
11433 | return; | 11433 | return; |
11434 | #ifdef O_APPEND | 11434 | #ifdef O_APPEND |
11435 | if ((flags = fcntl(fileno(tracefile), F_GETFL, 0)) >= 0) | 11435 | if ((flags = fcntl(fileno(tracefile), F_GETFL, 0)) >= 0) |
@@ -11482,7 +11482,7 @@ static int trapcmd(int argc, char **argv) | |||
11482 | if (action[0] == '-' && action[1] == '\0') | 11482 | if (action[0] == '-' && action[1] == '\0') |
11483 | action = NULL; | 11483 | action = NULL; |
11484 | else | 11484 | else |
11485 | action = xstrdup(action); | 11485 | action = bb_xstrdup(action); |
11486 | } | 11486 | } |
11487 | free(trap[signo]); | 11487 | free(trap[signo]); |
11488 | trap[signo] = action; | 11488 | trap[signo] = action; |
@@ -11700,7 +11700,7 @@ static void initvar() | |||
11700 | vpp = hashvar(ip->text); | 11700 | vpp = hashvar(ip->text); |
11701 | vp->next = *vpp; | 11701 | vp->next = *vpp; |
11702 | *vpp = vp; | 11702 | *vpp = vp; |
11703 | vp->text = xstrdup(ip->text); | 11703 | vp->text = bb_xstrdup(ip->text); |
11704 | vp->flags = ip->flags; | 11704 | vp->flags = ip->flags; |
11705 | vp->func = ip->func; | 11705 | vp->func = ip->func; |
11706 | } | 11706 | } |
@@ -11713,7 +11713,7 @@ static void initvar() | |||
11713 | vpp = hashvar("PS1=$ "); | 11713 | vpp = hashvar("PS1=$ "); |
11714 | vps1.next = *vpp; | 11714 | vps1.next = *vpp; |
11715 | *vpp = &vps1; | 11715 | *vpp = &vps1; |
11716 | vps1.text = xstrdup(geteuid()? "PS1=$ " : "PS1=# "); | 11716 | vps1.text = bb_xstrdup(geteuid()? "PS1=$ " : "PS1=# "); |
11717 | vps1.flags = VSTRFIXED | VTEXTFIXED; | 11717 | vps1.flags = VSTRFIXED | VTEXTFIXED; |
11718 | } | 11718 | } |
11719 | #endif | 11719 | #endif |
@@ -11833,7 +11833,7 @@ static void listsetvar(struct strlist *mylist) | |||
11833 | 11833 | ||
11834 | INTOFF; | 11834 | INTOFF; |
11835 | for (lp = mylist; lp; lp = lp->next) { | 11835 | for (lp = mylist; lp; lp = lp->next) { |
11836 | setvareq(xstrdup(lp->text), 0); | 11836 | setvareq(bb_xstrdup(lp->text), 0); |
11837 | } | 11837 | } |
11838 | INTON; | 11838 | INTON; |
11839 | } | 11839 | } |
@@ -11996,7 +11996,7 @@ static void mklocal(char *name) | |||
11996 | vp = *findvar(vpp, name); | 11996 | vp = *findvar(vpp, name); |
11997 | if (vp == NULL) { | 11997 | if (vp == NULL) { |
11998 | if (strchr(name, '=')) | 11998 | if (strchr(name, '=')) |
11999 | setvareq(xstrdup(name), VSTRFIXED); | 11999 | setvareq(bb_xstrdup(name), VSTRFIXED); |
12000 | else | 12000 | else |
12001 | setvar(name, NULL, VSTRFIXED); | 12001 | setvar(name, NULL, VSTRFIXED); |
12002 | vp = *vpp; /* the new variable */ | 12002 | vp = *vpp; /* the new variable */ |
@@ -12007,7 +12007,7 @@ static void mklocal(char *name) | |||
12007 | lvp->flags = vp->flags; | 12007 | lvp->flags = vp->flags; |
12008 | vp->flags |= VSTRFIXED | VTEXTFIXED; | 12008 | vp->flags |= VSTRFIXED | VTEXTFIXED; |
12009 | if (strchr(name, '=')) | 12009 | if (strchr(name, '=')) |
12010 | setvareq(xstrdup(name), 0); | 12010 | setvareq(bb_xstrdup(name), 0); |
12011 | } | 12011 | } |
12012 | } | 12012 | } |
12013 | lvp->vp = vp; | 12013 | lvp->vp = vp; |
@@ -12243,7 +12243,7 @@ int letcmd(int argc, char **argv) | |||
12243 | return 0; | 12243 | return 0; |
12244 | } | 12244 | } |
12245 | snprintf(p, 12, "%ld", result); | 12245 | snprintf(p, 12, "%ld", result); |
12246 | setvar(argv[1], xstrdup(p), 0); | 12246 | setvar(argv[1], bb_xstrdup(p), 0); |
12247 | } else if (argc >= 3) | 12247 | } else if (argc >= 3) |
12248 | synerror("invalid operand"); | 12248 | synerror("invalid operand"); |
12249 | return !result; | 12249 | return !result; |
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index 2ea61614d..3cbdce0ef 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
@@ -330,7 +330,7 @@ static void parse_prompt(const char *prmt_ptr) | |||
330 | char *pbuf; | 330 | char *pbuf; |
331 | 331 | ||
332 | if (!pwd_buf) { | 332 | if (!pwd_buf) { |
333 | pwd_buf=(char *)unknown; | 333 | pwd_buf=(char *)bb_msg_unknown; |
334 | } | 334 | } |
335 | 335 | ||
336 | while (*prmt_ptr) { | 336 | while (*prmt_ptr) { |
@@ -341,7 +341,7 @@ static void parse_prompt(const char *prmt_ptr) | |||
341 | const char *cp = prmt_ptr; | 341 | const char *cp = prmt_ptr; |
342 | int l; | 342 | int l; |
343 | 343 | ||
344 | c = process_escape_sequence(&prmt_ptr); | 344 | c = bb_process_escape_sequence(&prmt_ptr); |
345 | if(prmt_ptr==cp) { | 345 | if(prmt_ptr==cp) { |
346 | if (*cp == 0) | 346 | if (*cp == 0) |
347 | break; | 347 | break; |
@@ -430,7 +430,7 @@ static void parse_prompt(const char *prmt_ptr) | |||
430 | if (flg_not_length == ']') | 430 | if (flg_not_length == ']') |
431 | sub_len++; | 431 | sub_len++; |
432 | } | 432 | } |
433 | if(pwd_buf!=(char *)unknown) | 433 | if(pwd_buf!=(char *)bb_msg_unknown) |
434 | free(pwd_buf); | 434 | free(pwd_buf); |
435 | cmdedit_prompt = prmt_mem_ptr; | 435 | cmdedit_prompt = prmt_mem_ptr; |
436 | cmdedit_prmt_len = prmt_len - sub_len; | 436 | cmdedit_prmt_len = prmt_len - sub_len; |
@@ -520,8 +520,8 @@ static void cmdedit_init(void) | |||
520 | my_euid = geteuid(); | 520 | my_euid = geteuid(); |
521 | entry = getpwuid(my_euid); | 521 | entry = getpwuid(my_euid); |
522 | if (entry) { | 522 | if (entry) { |
523 | user_buf = xstrdup(entry->pw_name); | 523 | user_buf = bb_xstrdup(entry->pw_name); |
524 | home_pwd_buf = xstrdup(entry->pw_dir); | 524 | home_pwd_buf = bb_xstrdup(entry->pw_dir); |
525 | } | 525 | } |
526 | #endif | 526 | #endif |
527 | 527 | ||
@@ -598,7 +598,7 @@ static char **username_tab_completion(char *ud, int *num_matches) | |||
598 | /* Null usernames should result in all users as possible completions. */ | 598 | /* Null usernames should result in all users as possible completions. */ |
599 | if ( /*!userlen || */ !strncmp(ud, entry->pw_name, userlen)) { | 599 | if ( /*!userlen || */ !strncmp(ud, entry->pw_name, userlen)) { |
600 | 600 | ||
601 | bb_asprintf(&temp, "~%s/", entry->pw_name); | 601 | bb_xasprintf(&temp, "~%s/", entry->pw_name); |
602 | matches = xrealloc(matches, (nm + 1) * sizeof(char *)); | 602 | matches = xrealloc(matches, (nm + 1) * sizeof(char *)); |
603 | 603 | ||
604 | matches[nm++] = temp; | 604 | matches[nm++] = temp; |
@@ -647,7 +647,7 @@ static int path_parse(char ***p, int flags) | |||
647 | *p = xmalloc(npth * sizeof(char *)); | 647 | *p = xmalloc(npth * sizeof(char *)); |
648 | 648 | ||
649 | tmp = pth; | 649 | tmp = pth; |
650 | (*p)[0] = xstrdup(tmp); | 650 | (*p)[0] = bb_xstrdup(tmp); |
651 | npth = 1; /* count words is + 1 count ':' */ | 651 | npth = 1; /* count words is + 1 count ':' */ |
652 | 652 | ||
653 | for (;;) { | 653 | for (;;) { |
@@ -1071,7 +1071,7 @@ static void input_tab(int *lastWasTab) | |||
1071 | qsort(matches, num_matches, sizeof(char *), match_compare); | 1071 | qsort(matches, num_matches, sizeof(char *), match_compare); |
1072 | 1072 | ||
1073 | /* find minimal match */ | 1073 | /* find minimal match */ |
1074 | tmp = xstrdup(matches[0]); | 1074 | tmp = bb_xstrdup(matches[0]); |
1075 | for (tmp1 = tmp; *tmp1; tmp1++) | 1075 | for (tmp1 = tmp; *tmp1; tmp1++) |
1076 | for (len_found = 1; len_found < num_matches; len_found++) | 1076 | for (len_found = 1; len_found < num_matches; len_found++) |
1077 | if (matches[len_found][(tmp1 - tmp)] != *tmp1) { | 1077 | if (matches[len_found][(tmp1 - tmp)] != *tmp1) { |
@@ -1132,7 +1132,7 @@ static void get_previous_history(void) | |||
1132 | { | 1132 | { |
1133 | if(command_ps[0] != 0 || history[cur_history] == 0) { | 1133 | if(command_ps[0] != 0 || history[cur_history] == 0) { |
1134 | free(history[cur_history]); | 1134 | free(history[cur_history]); |
1135 | history[cur_history] = xstrdup(command_ps); | 1135 | history[cur_history] = bb_xstrdup(command_ps); |
1136 | } | 1136 | } |
1137 | cur_history--; | 1137 | cur_history--; |
1138 | } | 1138 | } |
@@ -1166,12 +1166,11 @@ extern void load_history ( const char *fromfile ) | |||
1166 | if (( fp = fopen ( fromfile, "r" ))) { | 1166 | if (( fp = fopen ( fromfile, "r" ))) { |
1167 | 1167 | ||
1168 | for ( hi = 0; hi < MAX_HISTORY; ) { | 1168 | for ( hi = 0; hi < MAX_HISTORY; ) { |
1169 | char * hl = get_line_from_file(fp); | 1169 | char * hl = bb_get_chomped_line_from_file(fp); |
1170 | int l; | 1170 | int l; |
1171 | 1171 | ||
1172 | if(!hl) | 1172 | if(!hl) |
1173 | break; | 1173 | break; |
1174 | chomp(hl); | ||
1175 | l = strlen(hl); | 1174 | l = strlen(hl); |
1176 | if(l >= BUFSIZ) | 1175 | if(l >= BUFSIZ) |
1177 | hl[BUFSIZ-1] = 0; | 1176 | hl[BUFSIZ-1] = 0; |
@@ -1500,7 +1499,7 @@ rewrite_line: | |||
1500 | for(i = 0; i < (MAX_HISTORY-1); i++) | 1499 | for(i = 0; i < (MAX_HISTORY-1); i++) |
1501 | history[i] = history[i+1]; | 1500 | history[i] = history[i+1]; |
1502 | } | 1501 | } |
1503 | history[i++] = xstrdup(command); | 1502 | history[i++] = bb_xstrdup(command); |
1504 | cur_history = i; | 1503 | cur_history = i; |
1505 | n_history = i; | 1504 | n_history = i; |
1506 | #if defined(CONFIG_FEATURE_SH_FANCY_PROMPT) | 1505 | #if defined(CONFIG_FEATURE_SH_FANCY_PROMPT) |
@@ -1535,7 +1534,7 @@ rewrite_line: | |||
1535 | 1534 | ||
1536 | #ifdef TEST | 1535 | #ifdef TEST |
1537 | 1536 | ||
1538 | const char *applet_name = "debug stuff usage"; | 1537 | const char *bb_applet_name = "debug stuff usage"; |
1539 | const char *memory_exhausted = "Memory exhausted"; | 1538 | const char *memory_exhausted = "Memory exhausted"; |
1540 | 1539 | ||
1541 | #ifdef CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT | 1540 | #ifdef CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT |
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; |
diff --git a/shell/lash.c b/shell/lash.c index 35929898e..8f864b355 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
@@ -246,7 +246,7 @@ static int builtin_cd(struct child_prog *child) | |||
246 | } | 246 | } |
247 | cwd = xgetcwd((char *)cwd); | 247 | cwd = xgetcwd((char *)cwd); |
248 | if (!cwd) | 248 | if (!cwd) |
249 | cwd = unknown; | 249 | cwd = bb_msg_unknown; |
250 | return EXIT_SUCCESS; | 250 | return EXIT_SUCCESS; |
251 | } | 251 | } |
252 | 252 | ||
@@ -284,12 +284,12 @@ static int builtin_fg_bg(struct child_prog *child) | |||
284 | } | 284 | } |
285 | } | 285 | } |
286 | if (!job) { | 286 | if (!job) { |
287 | error_msg("%s: no current job", child->argv[0]); | 287 | bb_error_msg("%s: no current job", child->argv[0]); |
288 | return EXIT_FAILURE; | 288 | return EXIT_FAILURE; |
289 | } | 289 | } |
290 | } else { | 290 | } else { |
291 | if (sscanf(child->argv[1], "%%%d", &jobnum) != 1) { | 291 | if (sscanf(child->argv[1], "%%%d", &jobnum) != 1) { |
292 | error_msg("%s: bad argument '%s'", child->argv[0], child->argv[1]); | 292 | bb_error_msg("%s: bad argument '%s'", child->argv[0], child->argv[1]); |
293 | return EXIT_FAILURE; | 293 | return EXIT_FAILURE; |
294 | } | 294 | } |
295 | for (job = child->family->job_list->head; job; job = job->next) { | 295 | for (job = child->family->job_list->head; job; job = job->next) { |
@@ -298,7 +298,7 @@ static int builtin_fg_bg(struct child_prog *child) | |||
298 | } | 298 | } |
299 | } | 299 | } |
300 | if (!job) { | 300 | if (!job) { |
301 | error_msg("%s: %d: no such job", child->argv[0], jobnum); | 301 | bb_error_msg("%s: %d: no such job", child->argv[0], jobnum); |
302 | return EXIT_FAILURE; | 302 | return EXIT_FAILURE; |
303 | } | 303 | } |
304 | } | 304 | } |
@@ -320,7 +320,7 @@ static int builtin_fg_bg(struct child_prog *child) | |||
320 | if (i == ESRCH) { | 320 | if (i == ESRCH) { |
321 | remove_job(&job_list, job); | 321 | remove_job(&job_list, job); |
322 | } else { | 322 | } else { |
323 | perror_msg("kill (SIGCONT)"); | 323 | bb_perror_msg("kill (SIGCONT)"); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
@@ -371,7 +371,7 @@ static int builtin_pwd(struct child_prog *dummy) | |||
371 | { | 371 | { |
372 | cwd = xgetcwd((char *)cwd); | 372 | cwd = xgetcwd((char *)cwd); |
373 | if (!cwd) | 373 | if (!cwd) |
374 | cwd = unknown; | 374 | cwd = bb_msg_unknown; |
375 | puts(cwd); | 375 | puts(cwd); |
376 | return EXIT_SUCCESS; | 376 | return EXIT_SUCCESS; |
377 | } | 377 | } |
@@ -489,7 +489,7 @@ static void mark_closed(int fd) | |||
489 | { | 489 | { |
490 | struct close_me *tmp; | 490 | struct close_me *tmp; |
491 | if (close_me_head == NULL || close_me_head->fd != fd) | 491 | if (close_me_head == NULL || close_me_head->fd != fd) |
492 | error_msg_and_die("corrupt close_me"); | 492 | bb_error_msg_and_die("corrupt close_me"); |
493 | tmp = close_me_head; | 493 | tmp = close_me_head; |
494 | close_me_head = close_me_head->next; | 494 | close_me_head = close_me_head->next; |
495 | free(tmp); | 495 | free(tmp); |
@@ -599,7 +599,7 @@ static void checkjobs(struct jobset *j_list) | |||
599 | } | 599 | } |
600 | 600 | ||
601 | if (childpid == -1 && errno != ECHILD) | 601 | if (childpid == -1 && errno != ECHILD) |
602 | perror_msg("waitpid"); | 602 | bb_perror_msg("waitpid"); |
603 | } | 603 | } |
604 | 604 | ||
605 | /* squirrel != NULL means we squirrel away copies of stdin, stdout, | 605 | /* squirrel != NULL means we squirrel away copies of stdin, stdout, |
@@ -628,7 +628,7 @@ static int setup_redirects(struct child_prog *prog, int squirrel[]) | |||
628 | if (openfd < 0) { | 628 | if (openfd < 0) { |
629 | /* this could get lost if stderr has been redirected, but | 629 | /* this could get lost if stderr has been redirected, but |
630 | bash and ash both lose it as well (though zsh doesn't!) */ | 630 | bash and ash both lose it as well (though zsh doesn't!) */ |
631 | perror_msg("error opening %s", redir->filename); | 631 | bb_perror_msg("error opening %s", redir->filename); |
632 | return 1; | 632 | return 1; |
633 | } | 633 | } |
634 | 634 | ||
@@ -803,7 +803,7 @@ static int expand_arguments(char *command) | |||
803 | while( command && command[ix]) { | 803 | while( command && command[ix]) { |
804 | if (command[ix] == '\\') { | 804 | if (command[ix] == '\\') { |
805 | const char *tmp = command+ix+1; | 805 | const char *tmp = command+ix+1; |
806 | command[ix] = process_escape_sequence( &tmp ); | 806 | command[ix] = bb_process_escape_sequence( &tmp ); |
807 | memmove(command+ix + 1, tmp, strlen(tmp)+1); | 807 | memmove(command+ix + 1, tmp, strlen(tmp)+1); |
808 | } | 808 | } |
809 | ix++; | 809 | ix++; |
@@ -816,7 +816,7 @@ static int expand_arguments(char *command) | |||
816 | 816 | ||
817 | /* We need a clean copy, so strsep can mess up the copy while | 817 | /* We need a clean copy, so strsep can mess up the copy while |
818 | * we write stuff into the original (in a minute) */ | 818 | * we write stuff into the original (in a minute) */ |
819 | cmd = cmd_copy = xstrdup(command); | 819 | cmd = cmd_copy = bb_xstrdup(command); |
820 | *command = '\0'; | 820 | *command = '\0'; |
821 | for (ix = 0, tmpcmd = cmd; | 821 | for (ix = 0, tmpcmd = cmd; |
822 | (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) { | 822 | (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) { |
@@ -829,13 +829,13 @@ static int expand_arguments(char *command) | |||
829 | if (retval == GLOB_NOSPACE) { | 829 | if (retval == GLOB_NOSPACE) { |
830 | /* Mem may have been allocated... */ | 830 | /* Mem may have been allocated... */ |
831 | globfree (&expand_result); | 831 | globfree (&expand_result); |
832 | error_msg(out_of_space); | 832 | bb_error_msg(out_of_space); |
833 | return FALSE; | 833 | return FALSE; |
834 | } else if (retval != 0) { | 834 | } else if (retval != 0) { |
835 | /* Some other error. GLOB_NOMATCH shouldn't | 835 | /* Some other error. GLOB_NOMATCH shouldn't |
836 | * happen because of the GLOB_NOCHECK flag in | 836 | * happen because of the GLOB_NOCHECK flag in |
837 | * the glob call. */ | 837 | * the glob call. */ |
838 | error_msg("syntax error"); | 838 | bb_error_msg("syntax error"); |
839 | return FALSE; | 839 | return FALSE; |
840 | } else { | 840 | } else { |
841 | /* Convert from char** (one word per string) to a simple char*, | 841 | /* Convert from char** (one word per string) to a simple char*, |
@@ -843,7 +843,7 @@ static int expand_arguments(char *command) | |||
843 | for (i=0; i < expand_result.gl_pathc; i++) { | 843 | for (i=0; i < expand_result.gl_pathc; i++) { |
844 | length=strlen(expand_result.gl_pathv[i]); | 844 | length=strlen(expand_result.gl_pathv[i]); |
845 | if (total_length+length+1 >= BUFSIZ) { | 845 | if (total_length+length+1 >= BUFSIZ) { |
846 | error_msg(out_of_space); | 846 | bb_error_msg(out_of_space); |
847 | return FALSE; | 847 | return FALSE; |
848 | } | 848 | } |
849 | strcat(command+total_length, " "); | 849 | strcat(command+total_length, " "); |
@@ -930,7 +930,7 @@ static int expand_arguments(char *command) | |||
930 | int subst_len = strlen(var); | 930 | int subst_len = strlen(var); |
931 | int trail_len = strlen(src); | 931 | int trail_len = strlen(src); |
932 | if (dst+subst_len+trail_len >= command+BUFSIZ) { | 932 | if (dst+subst_len+trail_len >= command+BUFSIZ) { |
933 | error_msg(out_of_space); | 933 | bb_error_msg(out_of_space); |
934 | return FALSE; | 934 | return FALSE; |
935 | } | 935 | } |
936 | /* Move stuff to the end of the string to accommodate | 936 | /* Move stuff to the end of the string to accommodate |
@@ -1006,7 +1006,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg) | |||
1006 | if (*src == '\\') { | 1006 | if (*src == '\\') { |
1007 | src++; | 1007 | src++; |
1008 | if (!*src) { | 1008 | if (!*src) { |
1009 | error_msg("character expected after \\"); | 1009 | bb_error_msg("character expected after \\"); |
1010 | free_job(job); | 1010 | free_job(job); |
1011 | return 1; | 1011 | return 1; |
1012 | } | 1012 | } |
@@ -1090,7 +1090,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg) | |||
1090 | chptr++; | 1090 | chptr++; |
1091 | 1091 | ||
1092 | if (!*chptr) { | 1092 | if (!*chptr) { |
1093 | error_msg("file name expected after %c", *(src-1)); | 1093 | bb_error_msg("file name expected after %c", *(src-1)); |
1094 | free_job(job); | 1094 | free_job(job); |
1095 | job->num_progs=0; | 1095 | job->num_progs=0; |
1096 | return 1; | 1096 | return 1; |
@@ -1109,7 +1109,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg) | |||
1109 | if (*prog->argv[argc_l] || saw_quote) | 1109 | if (*prog->argv[argc_l] || saw_quote) |
1110 | argc_l++; | 1110 | argc_l++; |
1111 | if (!argc_l) { | 1111 | if (!argc_l) { |
1112 | error_msg("empty command in pipe"); | 1112 | bb_error_msg("empty command in pipe"); |
1113 | free_job(job); | 1113 | free_job(job); |
1114 | job->num_progs=0; | 1114 | job->num_progs=0; |
1115 | return 1; | 1115 | return 1; |
@@ -1136,7 +1136,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg) | |||
1136 | src++; | 1136 | src++; |
1137 | 1137 | ||
1138 | if (!*src) { | 1138 | if (!*src) { |
1139 | error_msg("empty command in pipe"); | 1139 | bb_error_msg("empty command in pipe"); |
1140 | free_job(job); | 1140 | free_job(job); |
1141 | job->num_progs=0; | 1141 | job->num_progs=0; |
1142 | return 1; | 1142 | return 1; |
@@ -1155,7 +1155,7 @@ static int parse_command(char **command_ptr, struct job *job, int *inbg) | |||
1155 | case '\\': | 1155 | case '\\': |
1156 | src++; | 1156 | src++; |
1157 | if (!*src) { | 1157 | if (!*src) { |
1158 | error_msg("character expected after \\"); | 1158 | bb_error_msg("character expected after \\"); |
1159 | free_job(job); | 1159 | free_job(job); |
1160 | return 1; | 1160 | return 1; |
1161 | } | 1161 | } |
@@ -1217,7 +1217,7 @@ static int pseudo_exec(struct child_prog *child) | |||
1217 | /* Check if the command matches any of the forking builtins. */ | 1217 | /* Check if the command matches any of the forking builtins. */ |
1218 | for (x = bltins_forking; x->cmd; x++) { | 1218 | for (x = bltins_forking; x->cmd; x++) { |
1219 | if (strcmp(child->argv[0], x->cmd) == 0) { | 1219 | if (strcmp(child->argv[0], x->cmd) == 0) { |
1220 | applet_name=x->cmd; | 1220 | bb_applet_name=x->cmd; |
1221 | _exit (x->function(child)); | 1221 | _exit (x->function(child)); |
1222 | } | 1222 | } |
1223 | } | 1223 | } |
@@ -1225,7 +1225,7 @@ static int pseudo_exec(struct child_prog *child) | |||
1225 | /* Check if the command matches any busybox internal | 1225 | /* Check if the command matches any busybox internal |
1226 | * commands ("applets") here. Following discussions from | 1226 | * commands ("applets") here. Following discussions from |
1227 | * November 2000 on busybox@busybox.net, don't use | 1227 | * November 2000 on busybox@busybox.net, don't use |
1228 | * get_last_path_component(). This way explicit (with | 1228 | * bb_get_last_path_component(). This way explicit (with |
1229 | * slashes) filenames will never be interpreted as an | 1229 | * slashes) filenames will never be interpreted as an |
1230 | * applet, just like with builtins. This way the user can | 1230 | * applet, just like with builtins. This way the user can |
1231 | * override an applet with an explicit filename reference. | 1231 | * override an applet with an explicit filename reference. |
@@ -1241,7 +1241,7 @@ static int pseudo_exec(struct child_prog *child) | |||
1241 | * /bin/cat exists on the filesystem and is _not_ busybox. | 1241 | * /bin/cat exists on the filesystem and is _not_ busybox. |
1242 | * Some systems want this, others do not. Choose wisely. :-) | 1242 | * Some systems want this, others do not. Choose wisely. :-) |
1243 | */ | 1243 | */ |
1244 | name = get_last_path_component(name); | 1244 | name = bb_get_last_path_component(name); |
1245 | #endif | 1245 | #endif |
1246 | 1246 | ||
1247 | { | 1247 | { |
@@ -1255,7 +1255,7 @@ static int pseudo_exec(struct child_prog *child) | |||
1255 | 1255 | ||
1256 | execvp(child->argv[0], child->argv); | 1256 | execvp(child->argv[0], child->argv); |
1257 | 1257 | ||
1258 | /* Do not use perror_msg_and_die() here, since we must not | 1258 | /* Do not use bb_perror_msg_and_die() here, since we must not |
1259 | * call exit() but should call _exit() instead */ | 1259 | * call exit() but should call _exit() instead */ |
1260 | fprintf(stderr, "%s: %m\n", child->argv[0]); | 1260 | fprintf(stderr, "%s: %m\n", child->argv[0]); |
1261 | _exit(EXIT_FAILURE); | 1261 | _exit(EXIT_FAILURE); |
@@ -1299,7 +1299,7 @@ static void insert_job(struct job *newjob, int inbg) | |||
1299 | /* move the new process group into the foreground */ | 1299 | /* move the new process group into the foreground */ |
1300 | /* suppress messages when run from /linuxrc mag@sysgo.de */ | 1300 | /* suppress messages when run from /linuxrc mag@sysgo.de */ |
1301 | if (tcsetpgrp(shell_terminal, newjob->pgrp) && errno != ENOTTY) | 1301 | if (tcsetpgrp(shell_terminal, newjob->pgrp) && errno != ENOTTY) |
1302 | perror_msg("tcsetpgrp"); | 1302 | bb_perror_msg("tcsetpgrp"); |
1303 | } | 1303 | } |
1304 | } | 1304 | } |
1305 | 1305 | ||
@@ -1317,7 +1317,7 @@ static int run_command(struct job *newjob, int inbg, int outpipe[2]) | |||
1317 | child = & (newjob->progs[i]); | 1317 | child = & (newjob->progs[i]); |
1318 | 1318 | ||
1319 | if ((i + 1) < newjob->num_progs) { | 1319 | if ((i + 1) < newjob->num_progs) { |
1320 | if (pipe(pipefds)<0) perror_msg_and_die("pipe"); | 1320 | if (pipe(pipefds)<0) bb_perror_msg_and_die("pipe"); |
1321 | nextout = pipefds[1]; | 1321 | nextout = pipefds[1]; |
1322 | } else { | 1322 | } else { |
1323 | if (outpipe[1]!=-1) { | 1323 | if (outpipe[1]!=-1) { |
@@ -1464,7 +1464,7 @@ static int busy_loop(FILE * input) | |||
1464 | 1464 | ||
1465 | if (waitpid(job_list.fg->progs[i].pid, &status, WUNTRACED)<0) { | 1465 | if (waitpid(job_list.fg->progs[i].pid, &status, WUNTRACED)<0) { |
1466 | if (errno != ECHILD) { | 1466 | if (errno != ECHILD) { |
1467 | perror_msg_and_die("waitpid(%d)",job_list.fg->progs[i].pid); | 1467 | bb_perror_msg_and_die("waitpid(%d)",job_list.fg->progs[i].pid); |
1468 | } | 1468 | } |
1469 | } | 1469 | } |
1470 | 1470 | ||
@@ -1496,7 +1496,7 @@ static int busy_loop(FILE * input) | |||
1496 | /* move the shell to the foreground */ | 1496 | /* move the shell to the foreground */ |
1497 | /* suppress messages when run from /linuxrc mag@sysgo.de */ | 1497 | /* suppress messages when run from /linuxrc mag@sysgo.de */ |
1498 | if (tcsetpgrp(shell_terminal, getpgrp()) && errno != ENOTTY) | 1498 | if (tcsetpgrp(shell_terminal, getpgrp()) && errno != ENOTTY) |
1499 | perror_msg("tcsetpgrp"); | 1499 | bb_perror_msg("tcsetpgrp"); |
1500 | } | 1500 | } |
1501 | } | 1501 | } |
1502 | } | 1502 | } |
@@ -1504,7 +1504,7 @@ static int busy_loop(FILE * input) | |||
1504 | 1504 | ||
1505 | /* return controlling TTY back to parent process group before exiting */ | 1505 | /* return controlling TTY back to parent process group before exiting */ |
1506 | if (tcsetpgrp(shell_terminal, parent_pgrp) && errno != ENOTTY) | 1506 | if (tcsetpgrp(shell_terminal, parent_pgrp) && errno != ENOTTY) |
1507 | perror_msg("tcsetpgrp"); | 1507 | bb_perror_msg("tcsetpgrp"); |
1508 | 1508 | ||
1509 | /* return exit status if called with "-c" */ | 1509 | /* return exit status if called with "-c" */ |
1510 | if (input == NULL && WIFEXITED(status)) | 1510 | if (input == NULL && WIFEXITED(status)) |
@@ -1517,7 +1517,7 @@ static int busy_loop(FILE * input) | |||
1517 | #ifdef CONFIG_FEATURE_CLEAN_UP | 1517 | #ifdef CONFIG_FEATURE_CLEAN_UP |
1518 | void free_memory(void) | 1518 | void free_memory(void) |
1519 | { | 1519 | { |
1520 | if (cwd && cwd!=unknown) { | 1520 | if (cwd && cwd!=bb_msg_unknown) { |
1521 | free((char*)cwd); | 1521 | free((char*)cwd); |
1522 | } | 1522 | } |
1523 | if (local_pending_command) | 1523 | if (local_pending_command) |
@@ -1594,8 +1594,8 @@ int lash_main(int argc_l, char **argv_l) | |||
1594 | case 'c': | 1594 | case 'c': |
1595 | input = NULL; | 1595 | input = NULL; |
1596 | if (local_pending_command != 0) | 1596 | if (local_pending_command != 0) |
1597 | error_msg_and_die("multiple -c arguments"); | 1597 | bb_error_msg_and_die("multiple -c arguments"); |
1598 | local_pending_command = xstrdup(argv[optind]); | 1598 | local_pending_command = bb_xstrdup(argv[optind]); |
1599 | optind++; | 1599 | optind++; |
1600 | argv = argv+optind; | 1600 | argv = argv+optind; |
1601 | break; | 1601 | break; |
@@ -1603,7 +1603,7 @@ int lash_main(int argc_l, char **argv_l) | |||
1603 | interactive = TRUE; | 1603 | interactive = TRUE; |
1604 | break; | 1604 | break; |
1605 | default: | 1605 | default: |
1606 | show_usage(); | 1606 | bb_show_usage(); |
1607 | } | 1607 | } |
1608 | } | 1608 | } |
1609 | /* A shell is interactive if the `-i' flag was given, or if all of | 1609 | /* A shell is interactive if the `-i' flag was given, or if all of |
@@ -1627,14 +1627,14 @@ int lash_main(int argc_l, char **argv_l) | |||
1627 | #endif | 1627 | #endif |
1628 | } else if (local_pending_command==NULL) { | 1628 | } else if (local_pending_command==NULL) { |
1629 | //printf( "optind=%d argv[optind]='%s'\n", optind, argv[optind]); | 1629 | //printf( "optind=%d argv[optind]='%s'\n", optind, argv[optind]); |
1630 | input = xfopen(argv[optind], "r"); | 1630 | input = bb_xfopen(argv[optind], "r"); |
1631 | mark_open(fileno(input)); /* be lazy, never mark this closed */ | 1631 | mark_open(fileno(input)); /* be lazy, never mark this closed */ |
1632 | } | 1632 | } |
1633 | 1633 | ||
1634 | /* initialize the cwd -- this is never freed...*/ | 1634 | /* initialize the cwd -- this is never freed...*/ |
1635 | cwd = xgetcwd(0); | 1635 | cwd = xgetcwd(0); |
1636 | if (!cwd) | 1636 | if (!cwd) |
1637 | cwd = unknown; | 1637 | cwd = bb_msg_unknown; |
1638 | 1638 | ||
1639 | #ifdef CONFIG_FEATURE_CLEAN_UP | 1639 | #ifdef CONFIG_FEATURE_CLEAN_UP |
1640 | atexit(free_memory); | 1640 | atexit(free_memory); |
diff --git a/shell/msh.c b/shell/msh.c index 53f643de1..aad6bbf35 100644 --- a/shell/msh.c +++ b/shell/msh.c | |||
@@ -2838,7 +2838,7 @@ char *c, **v, **envp; | |||
2838 | #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL | 2838 | #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL |
2839 | char *name = c; | 2839 | char *name = c; |
2840 | #ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN | 2840 | #ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN |
2841 | name = get_last_path_component(name); | 2841 | name = bb_get_last_path_component(name); |
2842 | #endif | 2842 | #endif |
2843 | optind = 1; | 2843 | optind = 1; |
2844 | if (find_applet_by_name(name)) { | 2844 | if (find_applet_by_name(name)) { |
@@ -2876,7 +2876,7 @@ char *c, **v, **envp; | |||
2876 | return("no Shell"); | 2876 | return("no Shell"); |
2877 | 2877 | ||
2878 | case ENOMEM: | 2878 | case ENOMEM: |
2879 | return((char*)memory_exhausted); | 2879 | return((char*)bb_msg_memory_exhausted); |
2880 | 2880 | ||
2881 | case E2BIG: | 2881 | case E2BIG: |
2882 | return("argument list too long"); | 2882 | return("argument list too long"); |
@@ -3883,7 +3883,7 @@ int quoted; | |||
3883 | ; | 3883 | ; |
3884 | if (i < 0) { | 3884 | if (i < 0) { |
3885 | closepipe(pf); | 3885 | closepipe(pf); |
3886 | err((char*)memory_exhausted); | 3886 | err((char*)bb_msg_memory_exhausted); |
3887 | return(0); | 3887 | return(0); |
3888 | } | 3888 | } |
3889 | if (i != 0) { | 3889 | if (i != 0) { |