本文共 2345 字,大约阅读时间需要 7 分钟。
继续翻译
5.3.2 Choosing the Shell------------------------The program used as the shell is taken from the variable `SHELL'. Ifthis variable is not set in your makefile, the program `/bin/sh' isused as the shell. The argument(s) passed to the shell are taken fromthe variable `.SHELLFLAGS'. The default value of `.SHELLFLAGS' is `-c'normally, or `-ec' in POSIX-conforming mode. Unlike most variables, the variable `SHELL' is never set from theenvironment. This is because the `SHELL' environment variable is usedto specify your personal choice of shell program for interactive use.It would be very bad for personal choices like this to affect thefunctioning of makefiles. *Note Variables from the Environment:Environment. Furthermore, when you do set `SHELL' in your makefile that value is_not_ exported in the environment to recipe lines that `make' invokes.Instead, the value inherited from the user's environment, if any, isexported. You can override this behavior by explicitly exporting`SHELL' (*note Communicating Variables to a Sub-`make':Variables/Recursion.), forcing it to be passed in the environment torecipe lines. However, on MS-DOS and MS-Windows the value of `SHELL' in theenvironment *is* used, since on those systems most users do not setthis variable, and therefore it is most likely set specifically to beused by `make'. On MS-DOS, if the setting of `SHELL' is not suitablefor `make', you can set the variable `MAKESHELL' to the shell that`make' should use; if set it will be used as the shell instead of thevalue of `SHELL'.
5.3.2 选择Shell
------------------------作为shell 来运行的程序是由变量SHELL指定的。如果在你的makefile里面没有设定此变量,程序 /bin/sh将作为shell 被使用。传递给 shell的参数从变量 .SHELLFLAGS中来。.SHELLFLAGS的缺省值是-c,或者在POSIX-一致的模式下是 -ec。
不像大多数变量,变量SHELL永远不能从环境中设定。 这是因为SHELL环境变量是用来制定你的个人为了通系统交互的shell程序的。由于个人的选择而影响到makefile的运作是非常糟糕的。*Note Variables from the Environment:Environment.
而且, 当你确实在makefile中设定了SHELL,这个值不会输出到make的片段行所激活的环境中,反而,
Instead, 从用户环境中继承来的变量,会被导出。 你可以通过显式到处SHELL,来覆盖这种行为。(*note Communicating Variables to a Sub-`make':Variables/Recursion.), 将此值传递到片段行的环境中。然而,在MS-DOS 和 MS-Windows 环境中,SHELL 在环境中会被使用,因为在那些环境中,大多数的系统并不会设置这个变量,因此它最可能被make 使用。 在MS-DOS中,如果对SHELL的设置对make 不合适,你可以设置变量 MAKESHELL,告诉make 用哪个shell; 如果使用了这个变量,会优先于SHELL值。
后文待续
本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/09/28/2707235.html,如需转载请自行联系原作者