X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=shell%2Fash.c;h=c1b2b0ed658a4cdced95719c535bfb29d28eaf45;hb=d591a360d39f9bca3479b913fe4c5773965d18cf;hp=713898a9f598459fc59f37168df9f522dd0e1c63;hpb=6ab037872fa294d20d1f84403d1ac4dd4b8cbd86;p=oweals%2Fbusybox.git diff --git a/shell/ash.c b/shell/ash.c index 713898a9f..c1b2b0ed6 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -1312,6 +1312,7 @@ struct builtincmd { #define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2) #define IS_BUILTIN_ASSIGN(builtincmd) ((builtincmd)->name[0] & 4) +/* make sure to keep these in proper order since it is searched via bsearch() */ static const struct builtincmd builtincmd[] = { { BUILTIN_SPEC_REG ".", dotcmd }, { BUILTIN_SPEC_REG ":", truecmd }, @@ -1363,8 +1364,8 @@ static const struct builtincmd builtincmd[] = { { BUILTIN_SPEC_REG_ASSG "readonly", exportcmd }, { BUILTIN_SPEC_REG "return", returncmd }, { BUILTIN_SPEC_REG "set", setcmd }, - { BUILTIN_SPEC_REG "source", dotcmd }, { BUILTIN_SPEC_REG "shift", shiftcmd }, + { BUILTIN_SPEC_REG "source", dotcmd }, #ifdef CONFIG_ASH_BUILTIN_TEST { BUILTIN_REGULAR "test", testcmd }, #endif @@ -2034,7 +2035,6 @@ static void onsig(int); static int dotrap(void); static void setinteractive(int); static void exitshell(void) ATTRIBUTE_NORETURN; -static int decode_signal(const char *, int); /* * This routine is called when an error or an interrupt occurs in an @@ -2546,11 +2546,6 @@ onint(void) { int i; intpending = 0; -#if 0 - /* comment by vodz: its strange for me, this programm don`t use other - signal block */ - sigsetmask(0); -#endif i = EXSIG; if (gotsig[SIGINT - 1] && !trap[SIGINT]) { if (!(rootshell && iflag)) { @@ -3327,7 +3322,7 @@ evalcommand(union node *cmd, int flags) } sp = arglist.list; } - bb_full_write(preverrout_fd, "\n", 1); + full_write(preverrout_fd, "\n", 1); } cmd_is_exec = 0; @@ -3473,6 +3468,7 @@ evalbltin(const struct builtincmd *cmd, int argc, char **argv) { flushall(); cmddone: exitstatus |= ferror(stdout); + clearerr(stdout); commandname = savecmdname; exsig = 0; handler = savehandler; @@ -3737,9 +3733,7 @@ tryexec(char *cmd, char **argv, char **envp) #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL if(find_applet_by_name(cmd) != NULL) { /* re-exec ourselves with the new arguments */ - execve("/proc/self/exe",argv,envp); - /* If proc isn't mounted, try hardcoded path to busybox binary*/ - execve("/bin/busybox",argv,envp); + execve(CONFIG_BUSYBOX_EXEC_PATH,argv,envp); /* If they called chroot or otherwise made the binary no longer * executable, fall through */ } @@ -4565,7 +4559,7 @@ expandhere(union node *arg, int fd) { herefd = fd; expandarg(arg, (struct arglist *)NULL, 0); - bb_full_write(fd, stackblock(), expdest - (char *)stackblock()); + full_write(fd, stackblock(), expdest - (char *)stackblock()); } @@ -6017,7 +6011,7 @@ static inline void putprompt(const char *s) { #ifdef CONFIG_ASH_EXPAND_PRMT free(cmdedit_prompt); - cmdedit_prompt = bb_xstrdup(s); + cmdedit_prompt = xstrdup(s); #else cmdedit_prompt = s; #endif @@ -6553,7 +6547,7 @@ usage: } if (**++argv == '-') { - signo = decode_signal(*argv + 1, 1); + signo = get_signum(*argv + 1); if (signo < 0) { int c; @@ -6567,7 +6561,7 @@ usage: list = 1; break; case 's': - signo = decode_signal(optionarg, 1); + signo = get_signum(optionarg); if (signo < 0) { sh_error( "invalid signal number or name: %s", @@ -6593,14 +6587,14 @@ usage: if (!*argv) { for (i = 1; i < NSIG; i++) { - name = u_signal_names(0, &i, 1); - if (name) + name = get_signame(i); + if (isdigit(*name)) out1fmt(snlfmt, name); } return 0; } - name = u_signal_names(*argptr, &signo, -1); - if (name) + name = get_signame(signo); + if (isdigit(*name)) out1fmt(snlfmt, name); else sh_error("invalid signal number or exit status: %s", *argptr); @@ -8111,7 +8105,7 @@ static int dotcmd(int argc, char **argv) int status = 0; for (sp = cmdenviron; sp; sp = sp->next) - setvareq(bb_xstrdup(sp->text), VSTRFIXED | VTEXTFIXED); + setvareq(xstrdup(sp->text), VSTRFIXED | VTEXTFIXED); if (argc >= 2) { /* That's what SVR2 does */ char *fullname; @@ -8384,7 +8378,7 @@ growstackstr(void) { size_t len = stackblocksize(); if (herefd >= 0 && len >= 1024) { - bb_full_write(herefd, stackblock(), len); + full_write(herefd, stackblock(), len); return stackblock(); } growstackblock(); @@ -9027,8 +9021,7 @@ setcmd(int argc, char **argv) #ifdef CONFIG_ASH_GETOPTS static void -getoptsreset(value) - const char *value; +getoptsreset(const char *value) { shellparam.optind = number(value); shellparam.optoff = -1; @@ -9995,7 +9988,7 @@ static const char xxreadtoken_tokens[] = { #define xxreadtoken_singles \ (sizeof(xxreadtoken_chars) - xxreadtoken_doubles - 1) -static int xxreadtoken() +static int xxreadtoken(void) { int c; @@ -10980,7 +10973,7 @@ openhere(union node *redir) if (redir->type == NHERE) { len = strlen(redir->nhere.doc->narg.text); if (len <= PIPESIZE) { - bb_full_write(pip[1], redir->nhere.doc->narg.text, len); + full_write(pip[1], redir->nhere.doc->narg.text, len); goto out; } } @@ -10994,7 +10987,7 @@ openhere(union node *redir) #endif signal(SIGPIPE, SIG_DFL); if (redir->type == NHERE) - bb_full_write(pip[1], redir->nhere.doc->narg.text, len); + full_write(pip[1], redir->nhere.doc->narg.text, len); else expandhere(redir->nhere.doc, pip[1]); _exit(0); @@ -11623,9 +11616,7 @@ trapcmd(int argc, char **argv) if (trap[signo] != NULL) { const char *sn; - sn = u_signal_names(0, &signo, 0); - if (sn == NULL) - sn = "???"; + sn = get_signame(signo); out1fmt("trap -- %s %s\n", single_quote(trap[signo]), sn); } @@ -11637,7 +11628,7 @@ trapcmd(int argc, char **argv) else action = *ap++; while (*ap) { - if ((signo = decode_signal(*ap, 0)) < 0) + if ((signo = get_signum(*ap)) < 0) sh_error("%s: bad trap", *ap); INTOFF; if (action) { @@ -11940,14 +11931,6 @@ out: /* NOTREACHED */ } -static int decode_signal(const char *string, int minsig) -{ - int signo; - const char *name = u_signal_names(string, &signo, minsig); - - return name ? signo : -1; -} - /* var.c */ static struct var *vartab[VTABSIZE]; @@ -13474,7 +13457,7 @@ static const char op_tokens[] = { static arith_t arith (const char *expr, int *perrcode) { - register char arithval; /* Current character under analysis */ + char arithval; /* Current character under analysis */ operator lasttok, op; operator prec;