美文网首页
first&second

first&second

作者: tmax | 来源:发表于2018-07-07 00:21 被阅读0次

    first:

    #!/bin/bash
    film="the first film"
    echo "$film"
    ./second #创建子进程运行second,在子进程地址空间运行second
    echo "$film"
    

    second:

    #!/bin/bash
    echo "$film"
    film="the second film"
    echo "$film"
    

    对first、second添加可执行权限后
    执行

    ./first
    

    结果

    the first film
    
    the second film
    the first film
    

    将first改成

    #!/bin/bash
    film="the first film"
    echo "$film"
    . ./second #父进程运行second,在父进程地址空间运行second
    echo "$film"
    

    执行

    ./first
    

    结果

    the first film
    the first film
    the second film
    the second film
    


    将first改成

    #!/bin/bash
    film="the first film"
    echo "$film"
    export film
    ./second #创建子进程运行second,在子进程地址空间运行second
    echo "$film"
    

    执行

    ./first
    

    结果

    the first film
    the first film
    the second film
    the first film
    

    将first改为

    #!/bin/bash
    film="the first film"
    echo "$film"
    #export film
    film= `./second`
    echo "$film"
    

    将second改为

    #!/bin/bash
    #echo "$film"
    film="the second film"
    echo "$film"
    

    执行

    ./first
    

    结果

    the first film
    the second film #the second film被返回
    

    相关文章

      网友评论

          本文标题:first&second

          本文链接:https://www.haomeiwen.com/subject/pnlohftx.html