Changed so that 'PATH=newpath command' works, instead of looking at the

old path. Synced input.c with vangogh.
This commit is contained in:
christos 1995-06-09 01:53:44 +00:00
parent d7e904a697
commit a45947b2a4
4 changed files with 29 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: eval.c,v 1.25 1995/05/19 15:08:55 christos Exp $ */ /* $NetBSD: eval.c,v 1.26 1995/06/09 01:53:44 christos Exp $ */
/*- /*-
* Copyright (c) 1993 * Copyright (c) 1993
@ -38,9 +38,9 @@
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "@(#)eval.c 8.8 (Berkeley) 5/19/95"; static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
#else #else
static char rcsid[] = "$Header: /cvsroot/src/bin/sh/eval.c,v 1.25 1995/05/19 15:08:55 christos Exp $"; static char sccsid[] = "$NetBSD: eval.c,v 1.26 1995/06/09 01:53:44 christos Exp $";
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -677,7 +677,18 @@ evalcommand(cmd, flags, backcmd)
cmdentry.cmdtype = CMDBUILTIN; cmdentry.cmdtype = CMDBUILTIN;
cmdentry.u.index = BLTINCMD; cmdentry.u.index = BLTINCMD;
} else { } else {
find_command(argv[0], &cmdentry, 1); static const char PATH[] = "PATH=";
char *path = pathval();
/*
* Modify the command lookup path, if a PATH= assignment
* is present
*/
for (sp = varlist.list ; sp ; sp = sp->next)
if (strncmp(sp->text, PATH, sizeof(PATH) - 1) == 0)
path = sp->text + sizeof(PATH) - 1;
find_command(argv[0], &cmdentry, 1, path);
if (cmdentry.cmdtype == CMDUNKNOWN) { /* command not found */ if (cmdentry.cmdtype == CMDUNKNOWN) { /* command not found */
exitstatus = 1; exitstatus = 1;
flushout(&errout); flushout(&errout);
@ -876,7 +887,8 @@ prehash(n)
if (n->type == NCMD && n->ncmd.args) if (n->type == NCMD && n->ncmd.args)
if (goodname(n->ncmd.args->narg.text)) if (goodname(n->ncmd.args->narg.text))
find_command(n->ncmd.args->narg.text, &entry, 0); find_command(n->ncmd.args->narg.text, &entry, 0,
pathval());
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.c,v 1.16 1995/05/11 21:29:02 christos Exp $ */ /* $NetBSD: exec.c,v 1.17 1995/06/09 01:53:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -38,9 +38,9 @@
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "@(#)exec.c 8.3 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95";
#else #else
static char rcsid[] = "$NetBSD: exec.c,v 1.16 1995/05/11 21:29:02 christos Exp $"; static char rcsid[] = "$NetBSD: exec.c,v 1.17 1995/06/09 01:53:50 christos Exp $";
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -343,7 +343,7 @@ hashcmd(argc, argv)
&& (cmdp->cmdtype == CMDNORMAL && (cmdp->cmdtype == CMDNORMAL
|| (cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0))) || (cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0)))
delete_cmd_entry(); delete_cmd_entry();
find_command(name, &entry, 1); find_command(name, &entry, 1, pathval());
if (verbose) { if (verbose) {
if (entry.cmdtype != CMDUNKNOWN) { /* if no error msg */ if (entry.cmdtype != CMDUNKNOWN) { /* if no error msg */
cmdp = cmdlookup(name, 0); cmdp = cmdlookup(name, 0);
@ -404,15 +404,15 @@ printentry(cmdp, verbose)
*/ */
void void
find_command(name, entry, printerr) find_command(name, entry, printerr, path)
char *name; char *name;
struct cmdentry *entry; struct cmdentry *entry;
int printerr; int printerr;
char *path;
{ {
struct tblentry *cmdp; struct tblentry *cmdp;
int index; int index;
int prev; int prev;
char *path;
char *fullname; char *fullname;
struct stat statb; struct stat statb;
int e; int e;
@ -448,7 +448,6 @@ find_command(name, entry, printerr)
prev = cmdp->param.index; prev = cmdp->param.index;
} }
path = pathval();
e = ENOENT; e = ENOENT;
index = -1; index = -1;
loop: loop:

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.h,v 1.8 1995/05/11 21:29:05 christos Exp $ */ /* $NetBSD: exec.h,v 1.9 1995/06/09 01:53:53 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)exec.h 8.2 (Berkeley) 5/4/95 * @(#)exec.h 8.3 (Berkeley) 6/8/95
*/ */
/* values of cmdtype */ /* values of cmdtype */
@ -59,7 +59,7 @@ extern char *pathopt; /* set by padvance */
void shellexec __P((char **, char **, char *, int)); void shellexec __P((char **, char **, char *, int));
char *padvance __P((char **, char *)); char *padvance __P((char **, char *));
int hashcmd __P((int, char **)); int hashcmd __P((int, char **));
void find_command __P((char *, struct cmdentry *, int)); void find_command __P((char *, struct cmdentry *, int, char *));
int find_builtin __P((char *)); int find_builtin __P((char *));
void hashcd __P((void)); void hashcd __P((void));
void changepath __P((char *)); void changepath __P((char *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: input.c,v 1.15 1995/06/07 16:28:03 cgd Exp $ */ /* $NetBSD: input.c,v 1.16 1995/06/09 01:53:54 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -38,9 +38,9 @@
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "@(#)input.c 8.2 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)input.c 8.3 (Berkeley) 6/9/95";
#else #else
static char rcsid[] = "$NetBSD: input.c,v 1.15 1995/06/07 16:28:03 cgd Exp $"; static char rcsid[] = "$NetBSD: input.c,v 1.16 1995/06/09 01:53:54 christos Exp $";
#endif #endif
#endif /* not lint */ #endif /* not lint */