multi-line variable in tcsh

后端 未结 2 1279
太阳男子
太阳男子 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:46

    set help = 'my_script\
      -h : -help\
      -b : do boo'
    
    echo $help:q
    

    Another approach:

    alias help 'echo "my_script" ; echo "  -h : -help" ; echo "  -b : do boo"'
    
    help
    

    But see also: http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

    I've been using csh and tcsh for more years than I care to admit, but I had to resort to trial and error to figure out the first solution. For example, echo "$help" doesn't work; I don't know why, and I doubt that I could figure it out from the documentation.

    (In Bourne shell, you could do it like this:

    help() {
        cat <

    but csh and tcsh don't have functions.)

提交回复
热议问题