Ignore:
Timestamp:
Apr 21, 2007, 8:33:35 AM (18 years ago)
Author:
bird
Message:

hacking...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ash-messup/main.c

    r809 r879  
    8585STATIC union node *curcmd;
    8686STATIC union node *prevcmd;
    87 #if PROFILE
    88 short profile_buf[16384];
    89 extern int etext();
    90 #endif
    9187
    9288STATIC void read_profile(const char *);
     
    105101main(int argc, char **argv)
    106102{
     103        shinstance *psh;
     104
     105        setlocale(LC_ALL, "");
     106
     107        /*
     108         * Create the root shell instance.
     109         */
     110        psh = create_root_shell(NULL, argc, argv);
     111        if (!psh)
     112                return 2;
     113        return shell_main(psh, argc);
     114}       
     115
     116int
     117shell_main(shinstance *psh, int argc, char **argv)
     118{
    107119        struct jmploc jmploc;
    108120        struct stackmark smark;
     
    110122        char *shinit;
    111123
    112         setlocale(LC_ALL, "");
    113 
    114 #if PROFILE
    115         monitor(4, etext, profile_buf, sizeof profile_buf, 50);
    116 #endif
    117124        state = 0;
    118125        if (setjmp(jmploc.loc)) {
     
    166173                        goto state4;
    167174        }
    168         handler = &jmploc;
     175        psh->handler = &jmploc;
    169176#ifdef DEBUG
    170177#if DEBUG == 2
     
    174181        trputs("Shell args:  ");  trargs(argv);
    175182#endif
    176         rootpid = getpid();
    177         rootshell = 1;
     183        psh->rootpid = getpid();
     184        psh->rootshell = 1;
    178185#ifdef _MSC_VER
    179186    {
     
    187194        if (argv[0] && argv[0][0] == '-') {
    188195                state = 1;
    189                 read_profile("/etc/profile");
     196                read_profile(psh, "/etc/profile");
    190197state1:
    191198                state = 2;
    192                 read_profile(".profile");
     199                read_profile(psh, ".profile");
    193200        }
    194201state2:
    195202        state = 3;
    196203        if (getuid() == geteuid() && getgid() == getegid()) {
    197                 if ((shinit = lookupvar("ENV")) != NULL && *shinit != '\0') {
     204                if ((shinit = lookupvar(psh, "ENV")) != NULL && *shinit != '\0') {
    198205                        state = 3;
    199                         read_profile(shinit);
     206                        read_profile(psh, shinit);
    200207                }
    201208        }
     
    214221
    215222                for (i = 0; i < SIGSSIZE; i++)
    216                     setsignal(sigs[i], 0);
    217         }
    218 
    219         if (minusc)
    220                 evalstring(minusc, 0);
    221 
    222         if (sflag || minusc == NULL) {
     223                    setsignal(psh, sigs[i], 0);
     224        }
     225
     226        if (psh->minusc)
     227                evalstring(psh, psh->minusc, 0);
     228
     229        if (psh->sflag || minusc == NULL) {
    223230state4: /* XXX ??? - why isn't this before the "if" statement */
    224                 cmdloop(1);
    225         }
    226 #if PROFILE
    227         monitor(0);
    228 #endif
    229         exitshell(exitstatus);
     231                cmdloop(psh, 1);
     232        }
     233        exitshell(psh, psh->exitstatus);
    230234        /* NOTREACHED */
    231235}
Note: See TracChangeset for help on using the changeset viewer.