Peter Milne writes:
[oweals/busybox.git] / shell / ash.c
index 5072528f43090f749a716684dd6b5f558300eac3..977ae464722b16aa845cff715f44ca0a1f243287 100644 (file)
@@ -1446,7 +1446,7 @@ static void defun(char *, union node *);
 static void unsetfunc(const char *);
 
 #ifdef CONFIG_ASH_MATH_SUPPORT
-static int dash_arith(const char *);
+static long dash_arith(const char *);
 #endif
 
 #ifdef CONFIG_ASH_RANDOM_SUPPORT
@@ -3717,15 +3717,9 @@ tryexec(char *cmd, char **argv, char **envp)
        int flg_bb = 0;
        char *name = cmd;
 
-#ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
-       name = bb_get_last_path_component(name);
-       if(find_applet_by_name(name) != NULL)
-               flg_bb = 1;
-#else
        if(strchr(name, '/') == NULL && find_applet_by_name(name) != NULL) {
                flg_bb = 1;
        }
-#endif
        if(flg_bb) {
                char **ap;
                char **new;
@@ -8131,21 +8125,40 @@ find_dot_file(char *name)
        /* NOTREACHED */
 }
 
-int
-dotcmd(int argc, char **argv)
+static int dotcmd(int argc, char **argv)
 {
+       struct strlist *sp;
+       volatile struct shparam saveparam;
+
        exitstatus = 0;
 
-       if (argc >= 2) {                /* That's what SVR2 does */
+       for (sp = cmdenviron; sp; sp = sp->next)
+               setvareq(bb_xstrdup(sp->text), VSTRFIXED | VTEXTFIXED);
+
+       if (argc >= 2) {        /* That's what SVR2 does */
                char *fullname;
                struct stackmark smark;
 
                setstackmark(&smark);
                fullname = find_dot_file(argv[1]);
+
+               if (argc > 2) {
+                       saveparam = shellparam;
+                       shellparam.malloc = 0;
+                       shellparam.nparam = argc - 2;
+                       shellparam.p = argv + 2;
+               };
+
                setinputfile(fullname, 1);
                commandname = fullname;
                cmdloop(0);
                popfile();
+
+               if (argc > 2) {
+                       freeparam(&shellparam);
+                       shellparam = saveparam;
+               };
+
                popstackmark(&smark);
        }
        return exitstatus;
@@ -12475,7 +12488,7 @@ static int timescmd(int ac, char **av)
 }
 
 #ifdef CONFIG_ASH_MATH_SUPPORT
-static int
+static long
 dash_arith(const char *s)
 {
        long result;