Bash: pass variable as a single parameter / shell quote parameter

前端 未结 5 1387
孤街浪徒
孤街浪徒 2021-01-23 02:32

I\'m writing a bash script which has to pass a variable to another program:

./program $variable

The problem is, it is absolutely necessary for

5条回答
  •  无人及你
    2021-01-23 03:26

    Have a look on http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html .

    The problem is that the expansion of variables is done before of the command line parameters hence your behavior.

    You might work it arround with setting IFS to something weird as

    IFS='###' V='foo bar baz'; ./program $V 
    

提交回复
热议问题