From b6ff4ff920cf5798accf03ca1ac826688d01b4f0 Mon Sep 17 00:00:00 2001 From: harti Date: Tue, 24 May 2005 13:19:40 +0000 Subject: [PATCH] Use the name of the default shell instead of a numeric index to select the default shell. Idea from: DragonFlyBSD --- usr.bin/make/Makefile | 8 ++------ usr.bin/make/Makefile.dist | 2 +- usr.bin/make/job.c | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index 40903eb34b02..3cb53693dcc7 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -98,12 +98,8 @@ hash: # allow you to shoot yourself in the foot if you want to :-) MAKE_SHELL?= sh -.if ${MAKE_SHELL} == "csh" -CFLAGS+= -DDEFSHELL=0 -.elif ${MAKE_SHELL} == "sh" -CFLAGS+= -DDEFSHELL=1 -.elif ${MAKE_SHELL} == "ksh" -CFLAGS+= -DDEFSHELL=2 +.if ${MAKE_SHELL} == "csh" || ${MAKE_SHELL} == "sh" || ${MAKE_SHELL} == "ksh" +CFLAGS+= -DDEFSHELLNAME=\"${MAKE_SHELL}\" .else .error "MAKE_SHELL must be set to one of \"csh\", \"sh\" or \"ksh\"." .endif diff --git a/usr.bin/make/Makefile.dist b/usr.bin/make/Makefile.dist index 3432e389268d..0a485e1db01f 100644 --- a/usr.bin/make/Makefile.dist +++ b/usr.bin/make/Makefile.dist @@ -2,6 +2,6 @@ # a very simple makefile... pmake: @echo 'make started.' - cc -DDEFSHELL=1 -I. -c *.c + cc -DDEFSHELLNAME=\"sh\" -I. -c *.c cc *.o -o pmake @echo 'make completed.' diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index c2df52b6385a..6567afd6a2ed 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -2719,7 +2719,7 @@ Shell_Init(void) for (i = 0; shells_init[i] != NULL; i++) { sh = JobParseShellSpec(shells_init[i], &fullSpec); TAILQ_INSERT_TAIL(&shells, sh, link); - if (i == DEFSHELL) + if (strcmp(sh->name, DEFSHELLNAME) == 0) commandShell = sh; } }