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
@ -38,9 +38,9 @@
#ifndef lint
#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
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 /* not lint */
@ -677,7 +677,18 @@ evalcommand(cmd, flags, backcmd)
cmdentry.cmdtype = CMDBUILTIN;
cmdentry.u.index = BLTINCMD;
} 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 */
exitstatus = 1;
flushout(&errout);
@ -876,7 +887,8 @@ prehash(n)
if (n->type == NCMD && n->ncmd.args)
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
@ -38,9 +38,9 @@
#ifndef lint
#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
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 /* not lint */
@ -343,7 +343,7 @@ hashcmd(argc, argv)
&& (cmdp->cmdtype == CMDNORMAL
|| (cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0)))
delete_cmd_entry();
find_command(name, &entry, 1);
find_command(name, &entry, 1, pathval());
if (verbose) {
if (entry.cmdtype != CMDUNKNOWN) { /* if no error msg */
cmdp = cmdlookup(name, 0);
@ -404,15 +404,15 @@ printentry(cmdp, verbose)
*/
void
find_command(name, entry, printerr)
find_command(name, entry, printerr, path)
char *name;
struct cmdentry *entry;
int printerr;
char *path;
{
struct tblentry *cmdp;
int index;
int prev;
char *path;
char *fullname;
struct stat statb;
int e;
@ -448,7 +448,6 @@ find_command(name, entry, printerr)
prev = cmdp->param.index;
}
path = pathval();
e = ENOENT;
index = -1;
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
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)exec.h 8.2 (Berkeley) 5/4/95
* @(#)exec.h 8.3 (Berkeley) 6/8/95
*/
/* values of cmdtype */
@ -59,7 +59,7 @@ extern char *pathopt; /* set by padvance */
void shellexec __P((char **, char **, char *, int));
char *padvance __P((char **, 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 *));
void hashcd __P((void));
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
@ -38,9 +38,9 @@
#ifndef lint
#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
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 /* not lint */