tcsh中的多行变量 [英] multi-line variable in tcsh
问题描述
我想在tcsh中有一个变量来保存脚本的使用情况信息,因此在我的脚本中,每当我编写echo $ usage时,它将打印
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
-b : do boo
etc`。
有没有办法做到这一点?可以使用<< EOF?
Is there a way to do this? Can this be done using the << EOF ?
我尝试过类似的操作,但失败了:
I've tried something like this, but it failed:
set help = << EOF
my_script
-h : print help
-b : do boo
EOF
谢谢
推荐答案
set help = 'my_script\
-h : -help\
-b : do boo'
echo $help:q
另一种方法:
alias help 'echo "my_script" ; echo " -h : -help" ; echo " -b : do boo"'
help
但也请参见: http://www.faqs.org/faqs/unix-faq / shell / csh-whynot /
我使用csh和tcsh的时间超过了我想承认的时间,但是我不得不求助于试用错误找出第一个解决方案。例如, echo $ help
无效;我不知道为什么,而且我怀疑是否可以从文档中弄清楚。
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.
(在Bourne shell中,您可以这样执行:
(In Bourne shell, you could do it like this:
help() {
cat <<EOF
my_script
-h : -help
-b : do boo
EOF
}
help
,但是csh和tcsh没有功能。)
but csh and tcsh don't have functions.)
这篇关于tcsh中的多行变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!