V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
param
V2EX  ›  Bash

bash 的多行变量传递问题

  •  
  •   param · Jan 10, 2018 · 2834 views
    This topic created in 3041 days ago, the information mentioned may be changed or developed.
    #!/bin/bash            #1
    read -d '' sql << EOF  #2
    select c1, c2 from foo
    where c1='something'
    EOF
    echo "$sql"            #6
    export sql             #7
    bash -c 'echo $sql'    #8
    
    

    为什么第 6 行能正确输出多行变量,第 8 行就合并成单行了呢?

    2 replies    2018-01-10 05:01:27 +08:00
    ytterbium
        1
    ytterbium  
       Jan 10, 2018 via Android
    双引号
    param
        2
    param  
    OP
       Jan 10, 2018
    @ytterbium 咦!神奇。居然是这种错误。。知道问题了。。谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2756 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 15:37 · PVG 23:37 · LAX 08:37 · JFK 11:37
    ♥ Do have faith in what you're doing.