Move start_stop_daemon to debianutils.
[oweals/busybox.git] / shell / msh.c
index 92a0f8536f3bc7d097b85ecc16848ebc5395b1f9..a142c451af8b95761781aabe1dba3e68bda0b7bc 100644 (file)
@@ -3,7 +3,12 @@
  * Minix shell port for busybox
  *
  * This version of the Minix shell was adapted for use in busybox
- * by Erik Andersen <andersee@debian.org>
+ * by Erik Andersen <andersen@codepoet.org>
+ *
+ * - backtick expansion did not work properly
+ *   Jonas Holmberg <jonas.holmberg@axis.com>
+ *   Robert Schwebel <r.schwebel@pengutronix.de>
+ *   Erik Andersen <andersen@codepoet.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -52,6 +57,7 @@
 #define        LINELIM 2100
 #define        NPUSH   8       /* limit to input nesting */
 
+#undef NOFILE
 #define        NOFILE  20      /* Number of open files */
 #define        NUFILE  10      /* Number of user-accessible files */
 #define        FDBASE  10      /* First file usable by Shell */
@@ -213,14 +219,15 @@ static    char    *elinep;
 /*
  * other functions
  */
-static int (*inbuilt(char *s ))(void);
+static int(*inbuilt(char *s))(struct op *);
+
 
 static char *rexecve (char *c , char **v, char **envp );
 static char *space (int n );
 static char *strsave (char *s, int a );
 static char *evalstr (char *cp, int f );
 static char *putn (int n );
-static char *itoa (unsigned u, int n );
+static char *itoa (int n );
 static char *unquote (char *as );
 static struct var *lookup (char *n );
 static int rlookup (char *n );
@@ -394,7 +401,7 @@ struct ioarg {
 
 /* an input generator's state */
 struct io {
-       int     (*iofn)();
+       int     (*iofn)(struct  ioarg *, struct io *);
        struct  ioarg   *argp;
        int     peekc;
        char    prev;           /* previous character read by readc() */
@@ -429,7 +436,7 @@ static void freehere (int area );
 static void gethere (void);
 static void markhere (char *s, struct ioword *iop );
 static int herein (char *hname, int xdoll );
-static int run (struct ioarg *argp, int (*f)());
+static int run (struct ioarg *argp, int (*f)(struct ioarg *));
 
 /*
  * IO functions
@@ -446,7 +453,7 @@ static void closeall (void);
 /*
  * IO control
  */
-static void pushio (struct ioarg *argp, int (*fn)());
+static void pushio (struct ioarg *argp, int (*f)(struct ioarg *));
 static int remap (int fd );
 static int openpipe (int *pv );
 static void closepipe (int *pv );
@@ -496,8 +503,8 @@ static void echo(char **wp );
 static struct op **find1case (struct op *t, char *w );
 static struct op *findcase (struct op *t, char *w );
 static void brkset(struct brkcon *bc );
-static int dolabel(void);
-static int dohelp(void);
+static int dolabel(struct op *t );
+static int dohelp(struct op *t );
 static int dochdir(struct op *t );
 static int doshift(struct op *t );
 static int dologin(struct op *t );
@@ -509,7 +516,7 @@ static int doread(struct op *t );
 static int doeval(struct op *t );
 static int dotrap(struct op *t );
 static int getsig(char *s );
-static void setsig (int n, void (*f)());
+static void setsig (int n, sighandler_t f);
 static int getn(char *as );
 static int dobreak(struct op *t );
 static int docontinue(struct op *t );
@@ -517,11 +524,11 @@ static int brkcontin (char *cp, int val );
 static int doexit(struct op *t );
 static int doexport(struct op *t );
 static int doreadonly(struct op *t );
-static void rdexp (char **wp, void (*f)(), int key);
+static void rdexp (char **wp, void (*f)(struct var *), int key);
 static void badid(char *s );
 static int doset(struct op *t );
 static void varput (char *s, int out );
-static int dotimes(void);
+static int dotimes(struct op *t );
 static int expand (char *cp, struct wdblock **wbp, int f );
 static char *blank(int f );
 static int dollar(int quoted );
@@ -535,7 +542,7 @@ static void glob1 (char *base, char *lim );
 static void glob2 (char *i, char *j );
 static void glob3 (char *i, char *j, char *k );
 static void readhere (char **name, char *s, int ec );
-static void pushio(struct ioarg *argp, int (*fn)());
+static void pushio (struct ioarg *argp, int (*f)(struct ioarg *));
 static int xxchar(struct ioarg *ap );
 
 struct here {
@@ -595,7 +602,7 @@ static struct res restab[] = {
 
 struct builtincmd {
        const char *name;
-       int (*builtinfunc)();
+       int (*builtinfunc)(struct op *t);
 };
 static const struct    builtincmd      builtincmds[] = {
     {".",              dodot},
@@ -662,7 +669,6 @@ static int  heedint =1;
 static struct env e ={line, iostack, iostack-1, (xint *)NULL, FDBASE, (struct env *)NULL};
 static void (*qflag)(int) = SIG_IGN;
 static char    shellname[] = "/bin/sh";
-static char    search[] = ":/bin:/usr/bin";
 static int     startl;
 static int     peeksym;
 static int     nlseen;
@@ -681,11 +687,10 @@ static void * brktop;
 static void * brkaddr;
 
 
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
 static char * current_prompt;
 #endif
 
-
 /* -------- sh.c -------- */
 /*
  * shell
@@ -698,7 +703,7 @@ extern int msh_main(int argc, char **argv)
        register char *s;
        int cflag;
        char *name, **ap;
-       int (*iof)();
+       int (*iof)(struct ioarg *);
 
        initarea();
        if ((ap = environ) != NULL) {
@@ -720,11 +725,15 @@ extern int msh_main(int argc, char **argv)
                setval(homedir, "/");
        export(homedir);
 
-       setval(lookup("$"), itoa(getpid(), 5));
+       setval(lookup("$"), putn(getpid()));
 
        path = lookup("PATH");
-       if (path->value == null)
-               setval(path, search);
+       if (path->value == null) {
+               if (geteuid() == 0)
+                       setval(path, "/sbin:/bin:/usr/sbin:/usr/bin");
+               else
+                       setval(path, "/bin:/usr/bin");
+       }
        export(path);
 
        ifs = lookup("IFS");
@@ -732,7 +741,7 @@ extern int msh_main(int argc, char **argv)
                setval(ifs, " \t\n");
 
        prompt = lookup("PS1");
-#ifdef BB_FEATURE_SH_FANCY_PROMPT
+#ifdef CONFIG_FEATURE_SH_FANCY_PROMPT
        if (prompt->value == null)
 #endif
                setval(prompt, "$ ");
@@ -741,7 +750,7 @@ extern int msh_main(int argc, char **argv)
                prompt->status &= ~EXPORT;
        }
        cprompt = lookup("PS2");
-#ifdef BB_FEATURE_SH_FANCY_PROMPT
+#ifdef CONFIG_FEATURE_SH_FANCY_PROMPT
        if (cprompt->value == null)
 #endif
                setval(cprompt, "> ");
@@ -801,8 +810,10 @@ extern int msh_main(int argc, char **argv)
                PUSHIO(afile, 0, iof);
                if (isatty(0) && isatty(1) && !cflag) {
                        interactive++;
+#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET 
                        printf( "\n\n" BB_BANNER " Built-in shell (msh)\n");
                        printf( "Enter 'help' for a list of built-in commands.\n\n");
+#endif
                }
        }
        signal(SIGQUIT, qflag);
@@ -833,13 +844,15 @@ extern int msh_main(int argc, char **argv)
 
        for (;;) {
                if (interactive && e.iop <= iostack) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
                        current_prompt=prompt->value;
 #else
                        prs(prompt->value);
 #endif
                }
                onecommand();
+               /* Ensure that getenv("PATH") stays current */
+               setenv("PATH", path->value, 1);
        }
 }
 
@@ -852,7 +865,7 @@ setdash()
 
        cp = m;
        for (c='a'; c<='z'; c++)
-               if (flag[c])
+               if (flag[(int)c])
                        *cp++ = c;
        *cp = 0;
        setval(lookup("-"), m);
@@ -1041,37 +1054,20 @@ static char *
 putn(n)
 register int n;
 {
-       return(itoa(n, -1));
+       return(itoa(n));
 }
 
 static char *
-itoa(u, n)
-register unsigned u;
-int n;
+itoa(n)
+register int n;
 {
-       register char *cp;
        static char s[20];
-       int m;
-
-       m = 0;
-       if (n < 0 && (int) u < 0) {
-               m++;
-               u = -u;
-       }
-       cp = s+sizeof(s);
-       *--cp = 0;
-       do {
-               *--cp = u%10 + '0';
-               u /= 10;
-       } while (--n > 0 || u);
-       if (m)
-               *--cp = '-';
-       return(cp);
+       snprintf(s, sizeof(s), "%u", n);
+       return(s);
 }
 
 static void
-next(f)
-int f;
+next(int f)
 {
        PUSHIO(afile, f, filechar);
 }
@@ -1261,7 +1257,7 @@ static void
 ronly(vp)
 struct var *vp;
 {
-       if (isalpha(vp->name[0]))       /* not an internal symbol ($# etc) */
+       if (isalpha(vp->name[0]) || vp->name[0] == '_') /* not an internal symbol */
                vp->status |= RONLY;
 }
 
@@ -1269,10 +1265,10 @@ static int
 isassign(s)
 register char *s;
 {
-       if (!isalpha((int)*s))
+       if (!isalpha((int)*s) && *s != '_')
                return(0);
        for (; *s != '='; s++)
-               if (*s == 0 || !isalnum(*s))
+               if (*s == 0 || (!isalnum(*s) && *s != '_'))
                        return(0);
        return(1);
 }
@@ -1285,10 +1281,10 @@ int cf;
        register char *cp;
        struct var *vp;
 
-       if (!isalpha(*s))
+       if (!isalpha(*s) && *s != '_')
                return(0);
        for (cp = s; *cp != '='; cp++)
-               if (*cp == 0 || !isalnum(*cp))
+               if (*cp == 0 || (!isalnum(*cp) && *cp != '_'))
                        return(0);
        vp = lookup(s);
        nameval(vp, ++cp, cf == COPYV? (char *)NULL: s);
@@ -1301,10 +1297,10 @@ static int
 checkname(cp)
 register char *cp;
 {
-       if (!isalpha(*cp++))
+       if (!isalpha(*cp++) && *(cp-1) != '_')
                return(0);
        while (*cp)
-               if (!isalnum(*cp++))
+               if (!isalnum(*cp++) && *(cp-1) != '_')
                        return(0);
        return(1);
 }
@@ -1316,7 +1312,7 @@ register int f, out;
        register struct var *vp;
 
        for (vp = vlist; vp; vp = vp->next)
-               if (vp->status & f && isalpha(*vp->name)) {
+               if (vp->status & f && (isalpha(*vp->name) || *vp->name == '_')) {
                        if (vp->status & EXPORT)
                                write(out, "export ", 7);
                        if (vp->status & RONLY)
@@ -2169,7 +2165,7 @@ loop:
                startl = 1;
                if (multiline || cf & CONTIN) {
                        if (interactive && e.iop <= iostack) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
                        current_prompt=cprompt->value;
 #else
                        prs(cprompt->value);
@@ -2222,7 +2218,7 @@ register int c, c1;
                        return(YYERRCODE);
                }
                if (interactive && c == '\n' && e.iop <= iostack) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
                    current_prompt=cprompt->value;
 #else
                    prs(cprompt->value);
@@ -2321,6 +2317,9 @@ int act;
 
        switch(t->type) {
        case TPAREN:
+               rv = execute(t->left, pin, pout, 0);
+               break;
+                       
        case TCOM:
                {
                        int child;
@@ -2474,7 +2473,7 @@ static int
 forkexec( register struct op *t, int *pin, int *pout, int act, char **wp, int *pforked)
 {
        int i, rv;
-       int (*shcom)() = NULL;
+       int (*shcom)(struct op *) = NULL;
        register int f;
        char *cp = NULL;
        struct ioword **iopp;
@@ -2836,10 +2835,10 @@ char *c, **v, **envp;
        register char *sp, *tp;
        int eacces = 0, asis = 0;
 
-#ifdef BB_FEATURE_SH_STANDALONE_SHELL
+#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
        char *name = c;
-#ifdef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
-       name = get_last_path_component(name);
+#ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
+       name = bb_get_last_path_component(name);
 #endif
        optind = 1;
        if (find_applet_by_name(name)) {
@@ -2872,12 +2871,12 @@ char *c, **v, **envp;
                        *v = e.linep;
                        tp = *--v;
                        *v = e.linep;
-                       execve("/bin/sh", v, envp);
+                       execve(shellname, v, envp);
                        *v = tp;
                        return("no Shell");
 
                case ENOMEM:
-                       return("program too big");
+                       return((char*)bb_msg_memory_exhausted);
 
                case E2BIG:
                        return("argument list too long");
@@ -2895,9 +2894,7 @@ char *c, **v, **envp;
  * applied to stream `arg'.
  */
 static int
-run(argp, f)
-struct ioarg *argp;
-int (*f)();
+run(struct ioarg *argp, int (*f)(struct ioarg *))
 {
        struct op *otree;
        struct wdblock *swdlist;
@@ -2941,7 +2938,7 @@ int (*f)();
  * built-in commands: doX
  */
 
-static int dohelp()
+static int dohelp(struct op *t )
 {
        int col;
        const struct builtincmd *x;
@@ -2958,7 +2955,7 @@ static int dohelp()
                        col = 0;
                }
        }
-#ifdef BB_FEATURE_SH_STANDALONE_SHELL
+#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
        {
                int i;
                const struct BB_applet *applet;
@@ -2984,8 +2981,7 @@ static int dohelp()
 
 
 
-static int
-dolabel()
+static int dolabel(struct op *t )
 {
        return(0);
 }
@@ -3222,7 +3218,7 @@ char *s;
 }
 
 static void
-setsig( register int n, void (*f)(int))
+setsig( register int n, sighandler_t f)
 {
        if (n == 0)
                return;
@@ -3323,11 +3319,7 @@ struct op *t;
        return(0);
 }
 
-static void
-rdexp(wp, f, key)
-register char **wp;
-void (*f)();
-int key;
+static void rdexp (char **wp, void (*f)(struct var *), int key)
 {
        if (*wp != NULL) {
                for (; *wp != NULL; wp++) {
@@ -3406,7 +3398,7 @@ varput(s, out)
 register char *s;
 int out;
 {
-       if (isalnum(*s)) {
+       if (isalnum(*s) || *s == '_') {
                write(out, s, strlen(s));
                write(out, "\n", 1);
        }
@@ -3417,7 +3409,7 @@ int out;
  * Copyright (c) 1999 Herbert Xu <herbert@debian.org>
  * This file contains code for the times builtin.
  */
-static int dotimes ()
+static int dotimes(struct op *t )
 {
        struct tms buf;
        long int clk_tck = sysconf(_SC_CLK_TCK);
@@ -3436,7 +3428,7 @@ static int dotimes ()
 }
 
 
-static int (*inbuilt(char *s))()
+static int(*inbuilt(char *s))(struct op *)
 {
        const struct builtincmd *bp;
 
@@ -3444,7 +3436,7 @@ static int (*inbuilt(char *s))()
                if (strcmp(bp->name, s) == 0)
                        return(bp->builtinfunc);
 
-       return((int(*)())NULL);
+       return(NULL);
 }
 
 /* -------- eval.c -------- */
@@ -3613,7 +3605,7 @@ loop:
                c = 0;
        }
        unget(c);
-       if (!isalpha(c))
+       if (!isalpha(c) && c != '_')
                scanequals = 0;
        for (;;) {
                c = subgetc('"', foundequals);
@@ -3631,7 +3623,7 @@ loop:
                                foundequals = 1;
                                scanequals  = 0;
                        }
-                       else if (!isalnum(c))
+                       else if (!isalnum(c) && c != '_')
                                scanequals = 0;
                }
                *e.linep++ = c;
@@ -3645,7 +3637,7 @@ loop:
  */
 static int
 subgetc(ec, quoted)
-register int ec;
+register char ec;
 int quoted;
 {
        register char c;
@@ -3684,8 +3676,8 @@ int quoted;
        s = e.linep;
        if (c != '{') {
                *e.linep++ = c;
-               if (isalpha(c)) {
-                       while ((c = readc())!=0 && isalnum(c))
+               if (isalpha(c) || c == '_') {
+                       while ((c = readc())!=0 && (isalnum(c) || c == '_'))
                                if (e.linep < elinep)
                                        *e.linep++ = c;
                        unget(c);
@@ -3772,59 +3764,154 @@ int quoted;
 /*
  * Run the command in `...` and read its output.
  */
+
 static int
 grave(quoted)
 int quoted;
 {
-       register int i;
        char *cp;
+       register int i;
+       int j;
        int pf[2];
+       static char child_cmd[LINELIM];
+       char *src;
+       char *dest;
+       int count;
+       int ignore;
+       int ignore_once;
+       char *argument_list[4];
 
 #if __GNUC__
        /* Avoid longjmp clobbering */
        (void) &cp;
 #endif
+       
        for (cp = e.iop->argp->aword; *cp != '`'; cp++)
                if (*cp == 0) {
                        err("no closing `");
                        return(0);
                }
+
+       /* string copy with dollar expansion */
+       src = e.iop->argp->aword;
+       dest = child_cmd;
+       count = 0;
+       ignore = 0;
+       ignore_once = 0;
+       while ((*src != '`') && (count < LINELIM)) {
+               if (*src == '\'')
+                       ignore = !ignore;
+               if (*src == '\\')
+                       ignore_once = 1;
+               if (*src == '$' && !ignore && !ignore_once) {
+                       struct var *vp;
+                       char var_name[LINELIM];
+                       char alt_value[LINELIM];
+                       int var_index = 0;
+                       int alt_index = 0;
+                       char operator = 0;
+                       int braces = 0;
+                       char *value;
+
+                       src++;
+                       if (*src == '{') {
+                               braces = 1;
+                               src++;
+                       }
+
+                       var_name[var_index++] = *src++;
+                       while (isalnum(*src))
+                               var_name[var_index++] = *src++;
+                       var_name[var_index] = 0;
+
+                       if (braces) {
+                               switch (*src) {
+                               case '}':
+                                       break;
+                               case '-':
+                               case '=':
+                               case '+':
+                               case '?':
+                                       operator = *src;
+                                       break;
+                               default:
+                                       err("unclosed ${\n");
+                                       return(0);
+                               }
+                               if (operator) { 
+                                       src++;
+                                       while (*src && (*src != '}')) {
+                                               alt_value[alt_index++] = *src++;
+                                       }
+                                       alt_value[alt_index] = 0;
+                                       if (*src != '}') {
+                                               err("unclosed ${\n");
+                                               return(0);
+                                       }
+                               }
+                               src++;
+                       }
+
+                       vp = lookup(var_name);
+                       if (vp->value != null)
+                               value = (operator == '+')? alt_value : vp->value;
+                       else if (operator == '?') {
+                               err(alt_value);
+                               return(0);
+                       } else if (alt_index && (operator != '+')) {
+                               value = alt_value;
+                               if (operator == '=')
+                                       setval(vp, value);
+                       } else
+                               continue;
+
+                       while (*value && (count < LINELIM)) {
+                               *dest++ = *value++;
+                               count++;
+                       }
+               } else {
+                       *dest++ = *src++;
+                       count++;
+                       ignore_once = 0;
+               }
+       }
+       *dest = '\0';
+       
        if (openpipe(pf) < 0)
                return(0);
-       if ((i = vfork()) == -1) {
+       while ((i = vfork()) == -1 && errno == EAGAIN)
+               ;
+       if (i < 0) {
                closepipe(pf);
-               err("try again");
+               err((char*)bb_msg_memory_exhausted);
                return(0);
        }
        if (i != 0) {
+               waitpid(i, NULL, 0);
                e.iop->argp->aword = ++cp;
                close(pf[1]);
-               PUSHIO(afile, remap(pf[0]), quoted? qgravechar: gravechar);
+               PUSHIO(afile, remap(pf[0]), (int(*)(struct ioarg *))((quoted)? qgravechar: gravechar));
                return(1);
        }
-       *cp = 0;
        /* allow trapped signals */
-       for (i=0; i<=_NSIG; i++)
-               if (ourtrap[i] && signal(i, SIG_IGN) != SIG_IGN)
-                       signal(i, SIG_DFL);
+       /* XXX - Maybe this signal stuff should go as well? */
+       for (j=0; j<=_NSIG; j++)
+               if (ourtrap[j] && signal(j, SIG_IGN) != SIG_IGN)
+                       signal(j, SIG_DFL);
+       
        dup2(pf[1], 1);
        closepipe(pf);
-       flag['e'] = 0;
-       flag['v'] = 0;
-       flag['n'] = 0;
-       cp = strsave(e.iop->argp->aword, 0);
-       areanum = 1;
-       freehere(areanum);
-       freearea(areanum);      /* free old space */
-       e.oenv = NULL;
-       e.iop = (e.iobase = iostack) - 1;
-       unquote(cp);
-       interactive = 0;
-       PUSHIO(aword, cp, nlchar);
-       onecommand();
-       exit(1);
+
+       argument_list[0] = shellname;
+       argument_list[1] = "-c";
+       argument_list[2] = child_cmd;
+       argument_list[3] = 0;
+
+       prs(rexecve(argument_list[0], argument_list, makenv()));
+       _exit(1);
 }
 
+
 static char *
 unquote(as)
 register char *as;
@@ -4196,7 +4283,7 @@ static int my_getc( int ec)
                return(c);
        }
        c = readc();
-       if (ec != '\'' && e.iop->task != XGRAVE) {
+       if ((ec != '\'') && (ec != '`') && (e.iop->task != XGRAVE)) {
                if(c == '\\') {
                        c = readc();
                        if (c == '\n' && ec != '\"')
@@ -4254,7 +4341,7 @@ readc()
                        if (multiline)
                            return e.iop->prev = 0;
                        if (interactive && e.iop == iostack+1) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
                            current_prompt=prompt->value;
 #else
                            prs(prompt->value);
@@ -4278,9 +4365,7 @@ char c;
 }
 
 static void
-pushio(argp, fn)
-struct ioarg *argp;
-int (*fn)();
+pushio(struct ioarg *argp, int (*fn)(struct ioarg *))
 {
        if (++e.iop >= &iostack[NPUSH]) {
                e.iop--;
@@ -4288,7 +4373,7 @@ int (*fn)();
                gflg++;
                return;
        }
-       e.iop->iofn = fn;
+       e.iop->iofn = (int (*)(struct  ioarg *, struct io *))fn;
 
        if (argp->afid != AFID_NOBUF)
          e.iop->argp = argp;
@@ -4311,7 +4396,7 @@ int (*fn)();
        e.iop->nlcount = 0;
        if (fn == filechar || fn == linechar)
                e.iop->task = XIO;
-       else if (fn == gravechar || fn == qgravechar)
+       else if (fn == (int(*)(struct ioarg *))gravechar || fn == (int(*)(struct ioarg *))qgravechar)
                e.iop->task = XGRAVE;
        else
                e.iop->task = XOTHER;
@@ -4460,8 +4545,8 @@ register struct ioarg *ap;
          return *bp->bufp++ & 0177;
        }
 
-#ifdef BB_FEATURE_COMMAND_EDITING
-       if (interactive) {
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
+       if (interactive && isatty(ap->afile)) {
            static char mycommand[BUFSIZ];
            static int position = 0, size = 0;
 
@@ -4572,7 +4657,7 @@ static void
 prn(u)
 unsigned u;
 {
-       prs(itoa(u, 0));
+       prs(itoa(u));
 }
 
 static void
@@ -4715,11 +4800,11 @@ int ec;
        if (newenv(setjmp(errpt = ev)) != 0)
                unlink(tname);
        else {
-               pushio(e.iop->argp, e.iop->iofn);
+               pushio(e.iop->argp, (int(*)(struct ioarg *))e.iop->iofn);
                e.iobase = e.iop;
                for (;;) {
                    if (interactive && e.iop <= iostack) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
                            current_prompt=cprompt->value;
 #else
                            prs(cprompt->value);