Path: utzoo!attcan!uunet!vsedev!logan From: logan@vsedev.VSE.COM (James Logan III) Newsgroups: comp.unix.wizards Subject: Re: Echo Message-ID: <1264@vsedev.VSE.COM> Date: 1 Dec 88 02:16:25 GMT References: <6557@june.cs.washington.edu> Reply-To: logan@vsedev.VSE.COM (James Logan III) Organization: VSE Software Development Lab Lines: 50 In article <6557@june.cs.washington.edu> ka@june.cs.washington.edu (Kenneth Almquist) writes: # I've been implementing a public domain shell and I'm wondering what to # do about the echo builtin. The System V echo command interprets a number # of escape sequences (e.g. \n for newline) which the BSD echo does not, # so I can... # # 3. Don't provide an echo builtin, so users get whatever echo command is # installed in /bin. This follows the principle of least surprise, but # it makes shell scripts run slowly and does nothing for portability. # You should write a shell-script that is called by your makefile to test the echo in /bin and see which version is already installed. When you know which one is installed, just set an environment variable, like ECHOTYPE, to either "BSD_ECHO" or "SYSV_ECHO" and call "make echo.o". (Make calls the script "makemyshell4me" which calls "make echo.o" and returns to the first make. Get it? :-) In the makefile, just do something like this: # Uncomment ECHOTYPE and set it to BSD_ECHO or SYSV_ECHO # below to override the automatic configuration in the # "makemyshell4me" shell script. # ECHOTYPE = all: echo myshell echo: echo.c ./makemyshell4me echo.o: cc $(CCFLAGS) -D $(ECHOTYPE) echo.c myshell: echo.o other_modules.o cc $(LDFLAGS) echo.o other_modules.o This way the person who compiles your shell can either just type "make" and let your program automatically configure itself to use the echo like the one in that person's /bin, or he can explicitly specify the other version in the makefile by setting "ECHOTYPE" appropriately. -Jim -- Jim Logan logan@vsedev.vse.com (703) 892-0002 uucp: ..!uunet!vsedev!logan inet: logan%vsedev.vse.com@uunet.uu.net