summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2004-12-03 08:02:52 +0000
committerharti <harti@FreeBSD.org>2004-12-03 08:02:52 +0000
commit8345f29bee6dc779223d4805edfc48e7c533b3a7 (patch)
tree63b142f01f2d5f505ceba8bd530e19b232e5cfd0 /usr.bin
parentbeb94b5a212e644c63b1ec1d98f756d1abf4754e (diff)
downloadFreeBSD-src-8345f29bee6dc779223d4805edfc48e7c533b3a7.zip
FreeBSD-src-8345f29bee6dc779223d4805edfc48e7c533b3a7.tar.gz
Change the algorithm that matches the builtin shells from the name keyword
of the .SHELL target. Formerly it used to select the shell with the longest common trailing substring, so that bash would select sh, but pocsh would select csh. Now an exact match is required so that specifying bash without also giving a path and the other keywords will give an error. PR: Submitted by: Reviewed by: ru Approved by: Obtained from: MFC after:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/job.c48
1 files changed, 16 insertions, 32 deletions
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index 6e8db76..c21107d 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -2389,7 +2389,7 @@ Job_Empty(void)
* Find a matching shell in 'shells' given its final component.
*
* Results:
- * A pointer to a freshly allocated Shell structure with is a copy
+ * A pointer to a freshly allocated Shell structure with a copy
* of the static structure or NULL if no shell with the given name
* is found.
*
@@ -2402,45 +2402,29 @@ static Shell *
JobMatchShell(const char *name)
{
const struct CShell *sh; /* Pointer into shells table */
- const struct CShell *match; /* Longest-matching shell */
struct Shell *nsh;
- const char *cp1;
- const char *cp2;
- const char *eoname;
- eoname = name + strlen(name);
-
- match = NULL;
+ for (sh = shells; sh < shells + sizeof(shells) / sizeof(shells[0]); sh++)
+ if (strcmp(sh->name, name) == 0)
+ break;
- for (sh = shells; sh < shells + sizeof(shells) / sizeof(shells[0]); sh++) {
- for (cp1 = eoname - strlen(sh->name), cp2 = sh->name;
- *cp1 != '\0' && *cp1 == *cp2;
- cp1++, cp2++) {
- continue;
- }
- if (*cp1 != *cp2) {
- continue;
- } else if (match == NULL || strlen(match->name) < strlen(sh->name)) {
- match = sh;
- }
- }
- if (match == NULL)
+ if (sh == shells + sizeof(shells) / sizeof(shells[0]))
return (NULL);
/* make a copy */
nsh = emalloc(sizeof(*nsh));
- nsh->name = estrdup(match->name);
- nsh->echoOff = estrdup(match->echoOff);
- nsh->echoOn = estrdup(match->echoOn);
- nsh->hasEchoCtl = match->hasEchoCtl;
- nsh->noPrint = estrdup(match->noPrint);
- nsh->noPLen = match->noPLen;
- nsh->hasErrCtl = match->hasErrCtl;
- nsh->errCheck = estrdup(match->errCheck);
- nsh->ignErr = estrdup(match->ignErr);
- nsh->echo = estrdup(match->echo);
- nsh->exit = estrdup(match->exit);
+ nsh->name = estrdup(sh->name);
+ nsh->echoOff = estrdup(sh->echoOff);
+ nsh->echoOn = estrdup(sh->echoOn);
+ nsh->hasEchoCtl = sh->hasEchoCtl;
+ nsh->noPrint = estrdup(sh->noPrint);
+ nsh->noPLen = sh->noPLen;
+ nsh->hasErrCtl = sh->hasErrCtl;
+ nsh->errCheck = estrdup(sh->errCheck);
+ nsh->ignErr = estrdup(sh->ignErr);
+ nsh->echo = estrdup(sh->echo);
+ nsh->exit = estrdup(sh->exit);
return (nsh);
}
OpenPOWER on IntegriCloud