From: Ben F. <ben...@be...> - 2011-08-22 22:17:12
|
SourceForge.net <no...@so...> writes: > Submitted By: Jakub Wilk (ubanus) > > tools/editors/emacs/tests/Makefile has the following shebang: > #!/usr/bin/env make This will result in a commandline of ‘/usr/bin/env make Makefile’. > However, this doesn't quite work: > $ cd tools/editors/emacs/tests/ > $ chmod +x Makefile > $ ./Makefile > make: Nothing to be done for `Makefile'. Right. The shebang is not treating the arguments correctly. Note that the shebang line should be written with the assumption that the kernel will not do word splitting past the command path. So a maximum of two arguments can be specified: the command path, and optionally one argument. Comment By: Stefan Merten (smerten) > Of course it works. The message of `make` is a clear indication for > that. No, it's not. The word ‘Makefile’ is being given to the ‘make’ command as though it is a target to be satisfied, which of course is wrong. Submitted By: Jakub Wilk (ubanus) > I propose to remove the shebang completely. The right way to specify to ‘make’ where its rules should be read from – which is how to use ‘make’ as an interpreter for the file, as the semantics of a shebang line would suggest – is to use the ‘-f’ option to ‘make’. But because of the restriction mentioned above, the existing shebang line already has the maximum number of arguments. I think the ‘/usr/bin/env’ command should be removed from the shebang, and ‘/usr/bin/make’ used directly; this allows the ‘-f’ option to be the second argument. I propose to change the shebang line to a working one: #! /usr/bin/make -f That will cause the commandline of ‘/usr/bin/make -f Makefile’, and any user-supplied arguments would then correctly be interpreted by ‘make’ (e.g. ‘./Makefile tests’ → ‘/usr/bin/make -f ./Makefile tests’). -- \ “I just got out of the hospital; I was in a speed-reading | `\ accident. I hit a bookmark and flew across the room.” —Steven | _o__) Wright | Ben Finney |