zoukankan      html  css  js  c++  java
  • GNU make manual 翻译( 一百三十三)

    继续翻译

    5.3 Recipe Execution
    ====================
    
    When it is time to execute recipes to update a target, they are
    executed by invoking a new subshell for each line of the recipe, unless
    the `.ONESHELL' special target is in effect (*note Using One Shell: One
    Shell.)  (In practice, `make' may take shortcuts that do not affect the
    results.)
    
       *Please note:* this implies that setting shell variables and
    invoking shell commands such as `cd' that set a context local to each
    process will not affect the following lines in the recipe.(1)  If you
    want to use `cd' to affect the next statement, put both statements in a
    single recipe line.  Then `make' will invoke one shell to run the
    entire line, and the shell will execute the statements in sequence.
    For example:
    
         foo : bar/lose
                 cd $(@D) && gobble $(@F) > ../$@
    
    Here we use the shell AND operator (`&&') so that if the `cd' command
    fails, the script will fail without trying to invoke the `gobble'
    command in the wrong directory, which could cause problems (in this
    case it would certainly cause `../foo' to be truncated, at least).
    
       ---------- Footnotes ----------
    
       (1) On MS-DOS, the value of current working directory is *global*, so
    changing it _will_ affect the following recipe lines on those systems.

    5.3 片段执行
    ====================

    当到了执行片段去改变一个目的的时候,会通过为片段中的每一行激活一个新的子shell来执行。除非.ONESHELL 特殊目的起了效果(*note Using One Shell: One Shell)。

    *请注意:* 设置shell变量或者如cd 等命令来设置的本地上下文并不会影响后面的片段行。如果你想要用cd 来影响下一个句子,可以把所有的子句放入到一个单独的行里。 然后,make 会激活一个shell 来运行整个的行,并且shell 会按照序列运行这些句子:

    foo : bar/lose
    cd $(@D) && gobble $(@F) > ../$@

    这里我们使用 shell 的 与操作符 ,这样 如果 cd 命令失败,整个脚本将失败,不会再在错误的目录里激活 gobble 命令,不至于导致问题(在上述例子中,至少会导致 ../foo被 删除)

    ---------- 脚注 ----------

    (1) On MS-DOS, the value of current working directory is *global*, so
    changing it _will_ affect the following recipe lines on those systems.

    (1) 在 MS-DOS 系统里面,当前工作目录是 *global*, 因此改变了它的话,会影响后面的行。

    后文待续

  • 相关阅读:
    [转载]网站运营粮草要先行
    微信公众平台开发(一) 配置接口
    UI框架说明
    布局
    DataGrid表格控件
    Dialog控件
    mysql出现 too many connections
    JVM调优案例
    ArrayBlockingQueue源码阅读
    jdk命令行工具
  • 原文地址:https://www.cnblogs.com/gaojian/p/2706627.html
Copyright © 2011-2022 走看看