summaryrefslogtreecommitdiffstats
path: root/bin/sh/exec.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-02-05 14:01:46 +0000
committerjilles <jilles@FreeBSD.org>2011-02-05 14:01:46 +0000
commit852a80acf72e4c96489249a2958546b2155b3f2b (patch)
tree84915aacc0d57994a9e01403afbe1241feeb0859 /bin/sh/exec.c
parenta81357fbe93ddb2be80ff1401450234c412c135d (diff)
downloadFreeBSD-src-852a80acf72e4c96489249a2958546b2155b3f2b.zip
FreeBSD-src-852a80acf72e4c96489249a2958546b2155b3f2b.tar.gz
sh: Forget all cached command locations on any PATH change.
POSIX requires this and it is simpler than the previous code that remembered command locations when appending directories to PATH. In particular, PATH=$PATH is no longer a no-op but discards all cached command locations.
Diffstat (limited to 'bin/sh/exec.c')
-rw-r--r--bin/sh/exec.c25
1 files changed, 1 insertions, 24 deletions
diff --git a/bin/sh/exec.c b/bin/sh/exec.c
index 6297e9b..67eafff 100644
--- a/bin/sh/exec.c
+++ b/bin/sh/exec.c
@@ -494,30 +494,7 @@ hashcd(void)
void
changepath(const char *newval)
{
- const char *old, *new;
- int idx;
- int firstchange;
-
- old = pathval();
- new = newval;
- firstchange = 9999; /* assume no change */
- idx = 0;
- for (;;) {
- if (*old != *new) {
- firstchange = idx;
- if ((*old == '\0' && *new == ':')
- || (*old == ':' && *new == '\0'))
- firstchange++;
- old = new; /* ignore subsequent differences */
- }
- if (*new == '\0')
- break;
- if (*new == ':') {
- idx++;
- }
- new++, old++;
- }
- clearcmdentry(firstchange);
+ clearcmdentry(0);
}
OpenPOWER on IntegriCloud