Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ll-xn!cit-vax!polecat!fritz From: fritz@polecat.caltech.edu (Fritz Nordby) Newsgroups: comp.bugs.sys5 Subject: even more bugs in make Message-ID: <2888@cit-vax.Caltech.Edu> Date: Mon, 1-Jun-87 10:57:53 EDT Article-I.D.: cit-vax.2888 Posted: Mon Jun 1 10:57:53 1987 Date-Received: Wed, 3-Jun-87 00:44:22 EDT Sender: news@cit-vax.Caltech.Edu Reply-To: fritz@polecat.Caltech.EDU (Fritz Nordby) Distribution: world Organization: California Institute of Technology Lines: 52 Keywords: IFS, shell script, make Summary: shell scripts die if IFS is set I don't know if this has been noticed before, but there is a severe problem with make and Bourne shell scripts. If the IFS environment variable is set when make is invoked, then make resets IFS to an empty string. This almost guarantees that Bourne shell scripts will die horribly. To repeat, create an empty directory, cd there, and do: % /bin/sh $ cat >foo <makefile <y $ foo 1 2 3 3 3 $ IFS=' ' $ # that's IFS='' $ export IFS $ foo 1 2 3 3 3 $ make foo 1 2 3 3 1 $ ^D % The final "1" output by foo is the error. The problem is that the set "$@" in foo is being expanded into set "1" "2" "3" which, since IFS is empty (and therefore there are no field seperators), is interpreted as set "1 2 3" -- i.e., there is just one argument to set. Needless to say, this causes some problems. For example, suppose /bin/cc is a shell script which invokes the compiler after adding some flags to the comand line: #!/bin/sh exec /lib/cc -foo -bar "$@" If IFS is set when make is invoked, and if make invokes cc, then /lib/cc will be invoked with argc==2, as if it had been invoked by exec /lib/cc "-foo -bar $*" Fritz Nordby. fritz@vlsi.caltech.edu cit-vax!fritz