Changeset 1203 for trunk/src/kash/exec.c


Ignore:
Timestamp:
Oct 7, 2007, 3:39:01 AM (18 years ago)
Author:
bird
Message:

converted a few more files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/exec.c

    r1202 r1203  
    8686#endif
    8787
    88 
    89 #define CMDTABLESIZE 31         /* should be prime */
    90 #define ARB 1                   /* actual size determined at run time */
    91 
    92 
    93 
    94 struct tblentry {
    95         struct tblentry *next;  /* next entry in hash chain */
    96         union param param;      /* definition of builtin function */
    97         short cmdtype;          /* index identifying command */
    98         char rehash;            /* if set, cd done since entry created */
    99         char cmdname[ARB];      /* name of command */
    100 };
    101 
    102 
    103 STATIC struct tblentry *cmdtable[CMDTABLESIZE];
    104 STATIC int builtinloc = -1;             /* index in path of %builtin, or -1 */
    105 int exerrno = 0;                        /* Last exec error */
    106 
    107 
    108 STATIC void tryexec(char *, char **, char **, int, int);
    109 STATIC void execinterp(char **, char **);
    110 STATIC void printentry(struct tblentry *, int);
    111 STATIC void clearcmdentry(int);
    112 STATIC struct tblentry *cmdlookup(const char *, int);
    113 STATIC void delete_cmd_entry(void);
     88#include "shinstance.h"
     89
     90//#define CMDTABLESIZE 31               /* should be prime */
     91//#define ARB 1                 /* actual size determined at run time */
     92//
     93//
     94//
     95//struct tblentry {
     96//      struct tblentry *next;  /* next entry in hash chain */
     97//      union param param;      /* definition of builtin function */
     98//      short cmdtype;          /* index identifying command */
     99//      char rehash;            /* if set, cd done since entry created */
     100//      char cmdname[ARB];      /* name of command */
     101//};
     102//
     103//
     104//STATIC struct tblentry *cmdtable[CMDTABLESIZE];
     105//STATIC int builtinloc = -1;           /* index in path of %builtin, or -1 */
     106//int exerrno = 0;                      /* Last exec error */
     107
     108
     109STATIC void tryexec(shinstance *, char *, char **, char **, int, int);
     110STATIC void execinterp(shinstance *, char **, char **);
     111STATIC void printentry(shinstance *, struct tblentry *, int);
     112STATIC void clearcmdentry(shinstance *, int);
     113STATIC struct tblentry *cmdlookup(shinstance *, const char *, int);
     114STATIC void delete_cmd_entry(shinstance *);
    114115#ifdef PC_EXE_EXTS
    115 STATIC int stat_pc_exec_exts(char *fullname, struct stat *st, int has_ext);
     116STATIC int stat_pc_exec_exts(shinstance *, char *fullname, struct stat *st, int has_ext);
    116117#endif
    117118
     
    125126
    126127void
    127 shellexec(char **argv, char **envp, const char *path, int idx, int vforked)
     128shellexec(shinstance *psh, char **argv, char **envp, const char *path, int idx, int vforked)
    128129{
    129130        char *cmdname;
    130131        int e;
    131132#ifdef PC_EXE_EXTS
    132         int has_ext = strlen(argv[0]) - 4;
     133        int has_ext = (int)strlen(argv[0]) - 4;
    133134        has_ext = has_ext > 0
    134135            && argv[0][has_ext] == '.'
     
    148149                cmdname = stalloc(psh, strlen(argv[0]) + 5);
    149150                strcpy(cmdname, argv[0]);
    150                 tryexec(cmdname, argv, envp, vforked, has_ext);
     151                tryexec(psh, cmdname, argv, envp, vforked, has_ext);
    151152                TRACE((psh, "shellexec: cmdname=%s\n", cmdname));
    152153                stunalloc(psh, cmdname);
     
    155156                e = ENOENT;
    156157                while ((cmdname = padvance(psh, &path, argv[0])) != NULL) {
    157                         if (--idx < 0 && pathopt == NULL) {
    158                                 tryexec(cmdname, argv, envp, vforked, has_ext);
     158                        if (--idx < 0 && psh->pathopt == NULL) {
     159                                tryexec(psh, cmdname, argv, envp, vforked, has_ext);
    159160                                if (errno != ENOENT && errno != ENOTDIR)
    160161                                        e = errno;
     
    167168        switch (e) {
    168169        case EACCES:
    169                 exerrno = 126;
     170                psh->exerrno = 126;
    170171                break;
    171172        case ENOENT:
    172                 exerrno = 127;
     173                psh->exerrno = 127;
    173174                break;
    174175        default:
    175                 exerrno = 2;
     176                psh->exerrno = 2;
    176177                break;
    177178        }
    178179        TRACE((psh, "shellexec failed for '%s', errno %d, vforked %d, suppressint %d\n",
    179                 argv[0], e, vforked, suppressint ));
     180                argv[0], e, vforked, psh->suppressint ));
    180181        exerror(psh, EXEXEC, "%s: %s", argv[0], errmsg(psh, e, E_EXEC));
    181182        /* NOTREACHED */
     
    184185
    185186STATIC void
    186 tryexec(char *cmd, char **argv, char **envp, int vforked, int has_ext)
     187tryexec(shinstance *psh, char *cmd, char **argv, char **envp, int vforked, int has_ext)
    187188{
    188189        int e;
     
    196197        struct stat st;
    197198        if (!has_ext)
    198             stat_pc_exec_exts(cmd, &st, 0);
     199            stat_pc_exec_exts(psh, cmd, &st, 0);
    199200#endif
    200201#if defined __INNOTEK_LIBC__ && defined EXEC_HASH_BANG_SCRIPT
     
    204205#ifdef SYSV
    205206        do {
    206                 execve(cmd, argv, envp);
     207                sh_execve(psh, cmd, argv, envp);
    207208        } while (errno == EINTR);
    208209#else
    209         execve(cmd, argv, envp);
     210        sh_execve(psh, cmd, argv, envp);
    210211#endif
    211212        e = errno;
     
    220221                initshellproc(psh);
    221222                setinputfile(psh, cmd, 0);
    222                 commandname = arg0 = savestr(argv[0]);
     223                psh->commandname = psh->arg0 = savestr(argv[0]);
    223224#ifdef EXEC_HASH_BANG_SCRIPT
    224225                pgetc(psh); pungetc(psh);               /* fill up input buffer */
    225                 p = parsenextc;
    226                 if (parsenleft > 2 && p[0] == '#' && p[1] == '!') {
     226                p = psh->parsenextc;
     227                if (psh->parsenleft > 2 && p[0] == '#' && p[1] == '!') {
    227228                        argv[0] = cmd;
    228                         execinterp(argv, envp);
     229                        execinterp(psh, argv, envp);
    229230                }
    230231#endif
     
    250251
    251252STATIC void
    252 execinterp(char **argv, char **envp)
     253execinterp(shinstance *psh, char **argv, char **envp)
    253254{
    254255        int n;
     
    263264        char **new;
    264265
    265         n = parsenleft - 2;
    266         inp = parsenextc + 2;
     266        n = psh->parsenleft - 2;
     267        inp = psh->parsenextc + 2;
    267268        ap = newargs;
    268269        for (;;) {
     
    310311        while (*ap2++ = *ap++);
    311312        TRACE((psh, "hash bang '%s'\n", new[0]));
    312         shellexec(psh, new, envp, pathval(), 0, 0);
     313        shellexec(psh, new, envp, pathval(psh), 0, 0);
    313314        /* NOTREACHED */
    314315}
     
    323324 * the possible path expansions in sequence.  If an option (indicated by
    324325 * a percent sign) appears in the path entry then the global variable
    325  * pathopt will be set to point to it; otherwise pathopt will be set to
     326 * psh->pathopt will be set to point to it; otherwise psh->pathopt will be set to
    326327 * NULL.
    327328 */
    328329
    329 const char *pathopt;
     330//const char *pathopt;
    330331
    331332char *
    332 padvance(const char **path, const char *name)
     333padvance(shinstance *psh, const char **path, const char *name)
    333334{
    334335        const char *p;
     
    345346        for (p = start ; *p && *p != ':' && *p != '%' ; p++);
    346347#endif
    347         len = p - start + strlen(name) + 2;     /* "2" is for '/' and '\0' */
     348        len = (int)(p - start + strlen(name) + 2);      /* "2" is for '/' and '\0' */
    348349#ifdef PC_EXE_EXTS
    349350        len += 4; /* "4" is for .exe/.com/.cmd/.bat/.btm */
     
    358359        }
    359360        strcpy(q, name);
    360         pathopt = NULL;
     361        psh->pathopt = NULL;
    361362        if (*p == '%') {
    362                 pathopt = ++p;
     363                psh->pathopt = ++p;
    363364#ifdef PC_PATH_SEP
    364365                while (*p && *p != ';')  p++;
     
    380381
    381382#ifdef PC_EXE_EXTS
    382 STATIC int stat_pc_exec_exts(char *fullname, struct stat *st, int has_ext)
     383STATIC int stat_pc_exec_exts(shinstance *psh, char *fullname, struct stat *st, int has_ext)
    383384{
    384385    /* skip the SYSV crap */
    385     if (stat(fullname, st) >= 0)
     386    if (shfile_stat(&psh->fdtab, fullname, st) >= 0)
    386387        return 0;
    387388    if (!has_ext && errno == ENOENT)
     
    389390        char *psz = strchr(fullname, '\0');
    390391        memcpy(psz, ".exe", 5);
    391         if (stat(fullname, st) >= 0)
     392        if (shfile_stat(&psh->fdtab, fullname, st) >= 0)
    392393            return 0;
    393394        if (errno != ENOENT && errno != ENOTDIR)
     
    395396
    396397        memcpy(psz, ".cmd", 5);
    397         if (stat(fullname, st) >= 0)
     398        if (shfile_stat(&psh->fdtab, fullname, st) >= 0)
    398399            return 0;
    399400        if (errno != ENOENT && errno != ENOTDIR)
     
    401402
    402403        memcpy(psz, ".bat", 5);
    403         if (stat(fullname, st) >= 0)
     404        if (shfile_stat(&psh->fdtab, fullname, st) >= 0)
    404405            return 0;
    405406        if (errno != ENOENT && errno != ENOTDIR)
     
    407408
    408409        memcpy(psz, ".com", 5);
    409         if (stat(fullname, st) >= 0)
     410        if (shfile_stat(&psh->fdtab, fullname, st) >= 0)
    410411            return 0;
    411412        if (errno != ENOENT && errno != ENOTDIR)
     
    413414
    414415        memcpy(psz, ".btm", 5);
    415         if (stat(fullname, st) >= 0)
     416        if (shfile_stat(&psh->fdtab, fullname, st) >= 0)
    416417            return 0;
    417418        *psz = '\0';
     
    427428
    428429int
    429 hashcmd(int argc, char **argv)
     430hashcmd(shinstance *psh, int argc, char **argv)
    430431{
    431432        struct tblentry **pp;
     
    439440        while ((c = nextopt(psh, "rv")) != '\0') {
    440441                if (c == 'r') {
    441                         clearcmdentry(0);
     442                        clearcmdentry(psh, 0);
    442443                } else if (c == 'v') {
    443444                        verbose++;
    444445                }
    445446        }
    446         if (*argptr == NULL) {
    447                 for (pp = cmdtable ; pp < &cmdtable[CMDTABLESIZE] ; pp++) {
     447        if (*psh->argptr == NULL) {
     448                for (pp = psh->cmdtable ; pp < &psh->cmdtable[CMDTABLESIZE] ; pp++) {
    448449                        for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
    449450                                if (verbose || cmdp->cmdtype == CMDNORMAL)
    450                                         printentry(cmdp, verbose);
     451                                        printentry(psh, cmdp, verbose);
    451452                        }
    452453                }
    453454                return 0;
    454455        }
    455         while ((name = *argptr) != NULL) {
    456                 if ((cmdp = cmdlookup(name, 0)) != NULL
     456        while ((name = *psh->argptr) != NULL) {
     457                if ((cmdp = cmdlookup(psh, name, 0)) != NULL
    457458                 && (cmdp->cmdtype == CMDNORMAL
    458                      || (cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0)))
    459                         delete_cmd_entry();
    460                 find_command(psh, name, &entry, DO_ERR, pathval());
     459                     || (cmdp->cmdtype == CMDBUILTIN && psh->builtinloc >= 0)))
     460                        delete_cmd_entry(psh);
     461                find_command(psh, name, &entry, DO_ERR, pathval(psh));
    461462                if (verbose) {
    462463                        if (entry.cmdtype != CMDUNKNOWN) {      /* if no error msg */
    463                                 cmdp = cmdlookup(name, 0);
    464                                 printentry(cmdp, verbose);
     464                                cmdp = cmdlookup(psh, name, 0);
     465                                printentry(psh, cmdp, verbose);
    465466                        }
    466467                        output_flushall(psh);
    467468                }
    468                 argptr++;
     469                psh->argptr++;
    469470        }
    470471        return 0;
     
    473474
    474475STATIC void
    475 printentry(struct tblentry *cmdp, int verbose)
     476printentry(shinstance *psh, struct tblentry *cmdp, int verbose)
    476477{
    477478        int idx;
     
    482483        case CMDNORMAL:
    483484                idx = cmdp->param.index;
    484                 path = pathval();
     485                path = pathval(psh);
    485486                do {
    486487                        name = padvance(psh, &path, cmdp->cmdname);
     
    523524
    524525void
    525 find_command(char *name, struct cmdentry *entry, int act, const char *path)
     526find_command(shinstance *psh, char *name, struct cmdentry *entry, int act, const char *path)
    526527{
    527528        struct tblentry *cmdp, loc_cmd;
     
    531532        struct stat statb;
    532533        int e;
    533         int (*bltin)(int,char **);
     534        int (*bltin)(shinstance*,int,char **);
    534535
    535536#ifdef PC_EXE_EXTS
    536         int has_ext = strlen(name) - 4;
     537        int has_ext = (int)(strlen(name) - 4);
    537538        has_ext = has_ext > 0
    538539            && name[has_ext] == '.'
     
    550551        if (strchr(name, '/') != NULL) {
    551552                if (act & DO_ABS) {
    552                         while (stat(name, &statb) < 0) {
     553                        while (shfile_stat(&psh->fdtab, name, &statb) < 0) {
    553554#ifdef SYSV
    554555                                if (errno == EINTR)
     
    570571        }
    571572
    572         if (path != pathval())
     573        if (path != pathval(psh))
    573574                act |= DO_ALTPATH;
    574575
     
    577578
    578579        /* If name is in the table, check answer will be ok */
    579         if ((cmdp = cmdlookup(name, 0)) != NULL) {
     580        if ((cmdp = cmdlookup(psh, name, 0)) != NULL) {
    580581                do {
    581582                        switch (cmdp->cmdtype) {
     
    593594                                break;
    594595                        case CMDBUILTIN:
    595                                 if ((act & DO_ALTBLTIN) || builtinloc >= 0) {
     596                                if ((act & DO_ALTBLTIN) || psh->builtinloc >= 0) {
    596597                                        cmdp = NULL;
    597598                                        continue;
     
    606607
    607608        /* If %builtin not in path, check for builtin next */
    608         if ((act & DO_ALTPATH ? !(act & DO_ALTBLTIN) : builtinloc < 0) &&
     609        if ((act & DO_ALTPATH ? !(act & DO_ALTBLTIN) : psh->builtinloc < 0) &&
    609610            (bltin = find_builtin(psh, name)) != 0)
    610611                goto builtin_success;
     
    614615        if (cmdp) {             /* doing a rehash */
    615616                if (cmdp->cmdtype == CMDBUILTIN)
    616                         prev = builtinloc;
     617                        prev = psh->builtinloc;
    617618                else
    618619                        prev = cmdp->param.index;
     
    625626                stunalloc(psh, fullname);
    626627                idx++;
    627                 if (pathopt) {
    628                         if (prefix("builtin", pathopt)) {
     628                if (psh->pathopt) {
     629                        if (prefix("builtin", psh->pathopt)) {
    629630                                if ((bltin = find_builtin(psh, name)) == 0)
    630631                                        goto loop;
    631632                                goto builtin_success;
    632                         } else if (prefix("func", pathopt)) {
     633                        } else if (prefix("func", psh->pathopt)) {
    633634                                /* handled below */
    634635                        } else {
     
    645646                }
    646647#ifdef PC_EXE_EXTS
    647                 while (stat_pc_exec_exts(fullname, &statb, has_ext) < 0) {
     648                while (stat_pc_exec_exts(psh, fullname, &statb, has_ext) < 0) {
    648649#else
    649                 while (stat(fullname, &statb) < 0) {
     650                while (shfile_stat(&psh->fdtab, fullname, &statb) < 0) {
    650651#endif
    651652#ifdef SYSV
     
    661662                if (!S_ISREG(statb.st_mode))
    662663                        goto loop;
    663                 if (pathopt) {          /* this is a %func directory */
     664                if (psh->pathopt) {             /* this is a %func directory */
    664665                        if (act & DO_NOFUNC)
    665666                                goto loop;
    666667                        stalloc(psh, strlen(fullname) + 1);
    667668                        readcmdfile(psh, fullname);
    668                         if ((cmdp = cmdlookup(name, 0)) == NULL ||
     669                        if ((cmdp = cmdlookup(psh, name, 0)) == NULL ||
    669670                            cmdp->cmdtype != CMDFUNCTION)
    670671                                error(psh, "%s not defined in %s", name, fullname);
     
    692693                        cmdp = &loc_cmd;
    693694                } else
    694                         cmdp = cmdlookup(name, 1);
     695                        cmdp = cmdlookup(psh, name, 1);
    695696                cmdp->cmdtype = CMDNORMAL;
    696697                cmdp->param.index = idx;
     
    701702        /* We failed.  If there was an entry for this command, delete it */
    702703        if (cmdp)
    703                 delete_cmd_entry();
     704                delete_cmd_entry(psh);
    704705        if (act & DO_ERR)
    705706                outfmt(psh->out2, "%s: %s\n", name, errmsg(psh, e, E_EXEC));
     
    712713                cmdp = &loc_cmd;
    713714        else
    714                 cmdp = cmdlookup(name, 1);
     715                cmdp = cmdlookup(psh, name, 1);
    715716        if (cmdp->cmdtype == CMDFUNCTION)
    716717                /* DO_NOFUNC must have been set */
     
    732733
    733734int
    734 (*find_builtin(name))(int, char **)
    735         char *name;
     735(*find_builtin(shinstance *psh, char *name))(shinstance *psh, int, char **)
    736736{
    737737        const struct builtincmd *bp;
     
    745745
    746746int
    747 (*find_splbltin(name))(int, char **)
    748         char *name;
     747(*find_splbltin(shinstance *psh, char *name))(shinstance *psh, int, char **)
    749748{
    750749        const struct builtincmd *bp;
     
    765764
    766765void
    767 hash_special_builtins(void)
     766hash_special_builtins(shinstance *psh)
    768767{
    769768        const struct builtincmd *bp;
     
    771770
    772771        for (bp = splbltincmd ; bp->name ; bp++) {
    773                 cmdp = cmdlookup(bp->name, 1);
     772                cmdp = cmdlookup(psh, bp->name, 1);
    774773                cmdp->cmdtype = CMDSPLBLTIN;
    775774                cmdp->param.bltin = bp->builtin;
     
    785784
    786785void
    787 hashcd(void)
     786hashcd(shinstance *psh)
    788787{
    789788        struct tblentry **pp;
    790789        struct tblentry *cmdp;
    791790
    792         for (pp = cmdtable ; pp < &cmdtable[CMDTABLESIZE] ; pp++) {
     791        for (pp = psh->cmdtable ; pp < &psh->cmdtable[CMDTABLESIZE] ; pp++) {
    793792                for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
    794793                        if (cmdp->cmdtype == CMDNORMAL
    795                          || (cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0))
     794                         || (cmdp->cmdtype == CMDBUILTIN && psh->builtinloc >= 0))
    796795                                cmdp->rehash = 1;
    797796                }
     
    804803 * Fix command hash table when PATH changed.
    805804 * Called before PATH is changed.  The argument is the new value of PATH;
    806  * pathval() still returns the old value at this point.
     805 * pathval(psh) still returns the old value at this point.
    807806 * Called with interrupts off.
    808807 */
    809808
    810809void
    811 changepath(const char *newval)
     810changepath(shinstance *psh, const char *newval)
    812811{
    813812        const char *old, *new;
     
    816815        int bltin;
    817816
    818         old = pathval();
     817        old = pathval(psh);
    819818        new = newval;
    820819        firstchange = 9999;     /* assume no change */
     
    847846                new++, old++;
    848847        }
    849         if (builtinloc < 0 && bltin >= 0)
    850                 builtinloc = bltin;             /* zap builtins */
    851         if (builtinloc >= 0 && bltin < 0)
     848        if (psh->builtinloc < 0 && bltin >= 0)
     849                psh->builtinloc = bltin;                /* zap builtins */
     850        if (psh->builtinloc >= 0 && bltin < 0)
    852851                firstchange = 0;
    853         clearcmdentry(firstchange);
    854         builtinloc = bltin;
     852        clearcmdentry(psh, firstchange);
     853        psh->builtinloc = bltin;
    855854}
    856855
     
    862861
    863862STATIC void
    864 clearcmdentry(int firstchange)
     863clearcmdentry(shinstance *psh, int firstchange)
    865864{
    866865        struct tblentry **tblp;
     
    869868
    870869        INTOFF;
    871         for (tblp = cmdtable ; tblp < &cmdtable[CMDTABLESIZE] ; tblp++) {
     870        for (tblp = psh->cmdtable ; tblp < &psh->cmdtable[CMDTABLESIZE] ; tblp++) {
    872871                pp = tblp;
    873872                while ((cmdp = *pp) != NULL) {
     
    875874                             cmdp->param.index >= firstchange)
    876875                         || (cmdp->cmdtype == CMDBUILTIN &&
    877                              builtinloc >= firstchange)) {
     876                             psh->builtinloc >= firstchange)) {
    878877                                *pp = cmdp->next;
    879878                                ckfree(cmdp);
     
    905904
    906905void
    907 deletefuncs(void)
     906deletefuncs(shinstance *psh)
    908907{
    909908        struct tblentry **tblp;
     
    912911
    913912        INTOFF;
    914         for (tblp = cmdtable ; tblp < &cmdtable[CMDTABLESIZE] ; tblp++) {
     913        for (tblp = psh->cmdtable ; tblp < &psh->cmdtable[CMDTABLESIZE] ; tblp++) {
    915914                pp = tblp;
    916915                while ((cmdp = *pp) != NULL) {
     
    941940
    942941STATIC struct tblentry *
    943 cmdlookup(const char *name, int add)
     942cmdlookup(shinstance *psh, const char *name, int add)
    944943{
    945944        int hashval;
     
    953952                hashval += *p++;
    954953        hashval &= 0x7FFF;
    955         pp = &cmdtable[hashval % CMDTABLESIZE];
     954        pp = &psh->cmdtable[hashval % CMDTABLESIZE];
    956955        for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
    957956                if (equal(cmdp->cmdname, name))
     
    978977
    979978STATIC void
    980 delete_cmd_entry(void)
     979delete_cmd_entry(shinstance *psh)
    981980{
    982981        struct tblentry *cmdp;
     
    993992#ifdef notdef
    994993void
    995 getcmdentry(char *name, struct cmdentry *entry)
    996 {
    997         struct tblentry *cmdp = cmdlookup(name, 0);
     994getcmdentry(shinstance *psh, char *name, struct cmdentry *entry)
     995{
     996        struct tblentry *cmdp = cmdlookup(psh, name, 0);
    998997
    999998        if (cmdp) {
     
    10141013
    10151014STATIC void
    1016 addcmdentry(char *name, struct cmdentry *entry)
     1015addcmdentry(shinstance *psh, char *name, struct cmdentry *entry)
    10171016{
    10181017        struct tblentry *cmdp;
    10191018
    10201019        INTOFF;
    1021         cmdp = cmdlookup(name, 1);
     1020        cmdp = cmdlookup(psh, name, 1);
    10221021        if (cmdp->cmdtype != CMDSPLBLTIN) {
    10231022                if (cmdp->cmdtype == CMDFUNCTION) {
     
    10361035
    10371036void
    1038 defun(char *name, union node *func)
     1037defun(shinstance *psh,char *name, union node *func)
    10391038{
    10401039        struct cmdentry entry;
     
    10531052
    10541053int
    1055 unsetfunc(char *name)
     1054unsetfunc(shinstance *psh, char *name)
    10561055{
    10571056        struct tblentry *cmdp;
    10581057
    1059         if ((cmdp = cmdlookup(name, 0)) != NULL &&
     1058        if ((cmdp = cmdlookup(psh, name, 0)) != NULL &&
    10601059            cmdp->cmdtype == CMDFUNCTION) {
    10611060                freefunc(cmdp->param.func);
    1062                 delete_cmd_entry();
     1061                delete_cmd_entry(psh);
    10631062                return (0);
    10641063        }
     
    10721071
    10731072int
    1074 typecmd(int argc, char **argv)
     1073typecmd(shinstance *psh, int argc, char **argv)
    10751074{
    10761075        struct cmdentry entry;
     
    10961095                error(psh, "cannot specify -p with -v or -V");
    10971096
    1098         while ((arg = *argptr++)) {
     1097        while ((arg = *psh->argptr++)) {
    10991098                if (!v_flag)
    11001099                        out1str(psh, arg);
     
    11211120
    11221121                /* Then check if it is a tracked alias */
    1123                 if ((cmdp = cmdlookup(arg, 0)) != NULL) {
     1122                if ((cmdp = cmdlookup(psh, arg, 0)) != NULL) {
    11241123                        entry.cmdtype = cmdp->cmdtype;
    11251124                        entry.u = cmdp->param;
    11261125                } else {
    11271126                        /* Finally use brute force */
    1128                         find_command(psh, arg, &entry, DO_ABS, pathval());
     1127                        find_command(psh, arg, &entry, DO_ABS, pathval(psh));
    11291128                }
    11301129
     
    11321131                case CMDNORMAL: {
    11331132                        if (strchr(arg, '/') == NULL) {
    1134                                 const char *path = pathval();
     1133                                const char *path = pathval(psh);
    11351134                                char *name;
    11361135                                int j = entry.u.index;
Note: See TracChangeset for help on using the changeset viewer.