multi-line variable in tcsh

后端 未结 2 1266
太阳男子
太阳男子 2021-01-12 15:08

I want to have variable in tcsh to hold the usage info of my script, so in my script, whenever I write echo $usage, it will print

my_script
  -h : -help
  -         


        
2条回答
  •  粉色の甜心
    2021-01-12 15:41

    Using '' stops variables being evaluated, not an issue in your case but can be in other situations. To make it a little more readable and allowing the string to be spread over multiple lines I use the following:

    #!/bin/tcsh
    
    set help =      "my_script   \n" 
    set help = "$help  -h : -help\n"
    set help = "$help  -b : do boo"
    
    echo $help:q
    

提交回复
热议问题