Changeset 3271


Ignore:
Timestamp:
May 1, 2007, 6:53:12 PM (18 years ago)
Author:
bird
Message:

translate /bin/sh and a few other standard things to /@unixroot and PATH searches.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ash/exec.c

    r3229 r3271  
    230230                exraise(EXSHELLPROC);
    231231        }
     232#ifdef __OS2__
     233        /* A lot of scripts references some core /bin/ programs, like for
     234           instance the bash testcases. So, to make life easier, we map
     235           a small set of these to @unixroot and or the PATH to simplify
     236           porting. */
     237        else if (!strncmp(cmd, "/bin/", sizeof("/bin/") - 1)) {
     238                char *name = cmd+ sizeof("/bin/") - 1;
     239                int search_path = 1;
     240                if (!strcmp(name, "sh")
     241                 || !strcmp(name, "sh.exe")
     242                 || !strcmp(name, "bash")
     243                 || !strcmp(name, "bash.exe")
     244                 || !strcmp(name, "ash")
     245                 || !strcmp(name, "ash.exe")
     246                 || !strcmp(name, "ls")
     247                 || !strcmp(name, "ls.exe")
     248                 || !strcmp(name, "cat")
     249                 || !strcmp(name, "cat.exe")
     250                 || !strcmp(name, "mkdir")
     251                 || !strcmp(name, "mkdir.exe")
     252                 || !strcmp(name, "expr")
     253                 || !strcmp(name, "expr.exe")
     254                 || !strcmp(name, "pwd")
     255                 || !strcmp(name, "pwd.exe")
     256                 || !strcmp(name, "tr")
     257                 || !strcmp(name, "tr.exe")
     258                 || (search_path = 0)
     259                 || !strcmp(name, "sort")
     260                 || !strcmp(name, "sort.exe")
     261                 || !strcmp(name, "cp")
     262                 || !strcmp(name, "cp.exe")
     263                 || !strcmp(name, "rm")
     264                 || !strcmp(name, "rm.exe")
     265                 || !strcmp(name, "unlink")
     266                 || !strcmp(name, "unlink.exe")
     267                 || !strcmp(name, "mv")
     268                 || !strcmp(name, "mv.exe")
     269                 || !strcmp(name, "rmdir")
     270                 || !strcmp(name, "rmdir.exe")
     271                ) {
     272                        char tmp[48];
     273                        strcat(strcpy(tmp, "/@unixroot"), cmd);
     274                        execve(tmp, argv, envp);
     275                        if (search_path) {
     276                                strcpy(tmp, name);
     277                                if (!strchr(name, '.'))
     278                                        strcat(tmp, ".exe");
     279                                execvpe(tmp, argv, envp);
     280                        }
     281                }
     282        }
     283#endif
    232284        errno = e;
    233285}
Note: See TracChangeset for help on using the changeset viewer.