summaryrefslogtreecommitdiffstats
path: root/bin/sh/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/sh/exec.c')
-rw-r--r--bin/sh/exec.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/bin/sh/exec.c b/bin/sh/exec.c
index d983849..85794d9 100644
--- a/bin/sh/exec.c
+++ b/bin/sh/exec.c
@@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$");
struct tblentry {
struct tblentry *next; /* next entry in hash chain */
union param param; /* definition of builtin function */
+ int special; /* flag for special builtin commands */
short cmdtype; /* index identifying command */
char rehash; /* if set, cd done since entry created */
char cmdname[ARB]; /* name of command */
@@ -317,6 +318,7 @@ find_command(char *name, struct cmdentry *entry, int printerr, char *path)
struct stat statb;
int e;
int i;
+ int spec;
/* If name contains a slash, don't use the hash table */
if (strchr(name, '/') != NULL) {
@@ -330,11 +332,12 @@ find_command(char *name, struct cmdentry *entry, int printerr, char *path)
goto success;
/* If %builtin not in path, check for builtin next */
- if (builtinloc < 0 && (i = find_builtin(name)) >= 0) {
+ if (builtinloc < 0 && (i = find_builtin(name, &spec)) >= 0) {
INTOFF;
cmdp = cmdlookup(name, 1);
cmdp->cmdtype = CMDBUILTIN;
cmdp->param.index = i;
+ cmdp->special = spec;
INTON;
goto success;
}
@@ -356,12 +359,13 @@ loop:
index++;
if (pathopt) {
if (prefix("builtin", pathopt)) {
- if ((i = find_builtin(name)) < 0)
+ if ((i = find_builtin(name, &spec)) < 0)
goto loop;
INTOFF;
cmdp = cmdlookup(name, 1);
cmdp->cmdtype = CMDBUILTIN;
cmdp->param.index = i;
+ cmdp->special = spec;
INTON;
goto success;
} else if (prefix("func", pathopt)) {
@@ -430,6 +434,7 @@ success:
cmdp->rehash = 0;
entry->cmdtype = cmdp->cmdtype;
entry->u = cmdp->param;
+ entry->special = cmdp->special;
}
@@ -439,13 +444,15 @@ success:
*/
int
-find_builtin(char *name)
+find_builtin(char *name, int *special)
{
const struct builtincmd *bp;
for (bp = builtincmd ; bp->name ; bp++) {
- if (*bp->name == *name && equal(bp->name, name))
+ if (*bp->name == *name && equal(bp->name, name)) {
+ *special = bp->special;
return bp->code;
+ }
}
return -1;
}
OpenPOWER on IntegriCloud