如何制作脚本的help

如何制作脚本的help

脚本(xtitlebar)如下:

#!/bin/bash
# vim: set sw=4 ts=4 et:

help()
{
cat < xtitlebar -- change the name of an xterm, gnome-terminal or kde konsole

USAGE: xtitlebar [-h] "string_for_titelbar"

OPTIONS: -h help text

EXAMPLE: xtitlebar "cvs"

HELP
exit ()
}

# in case of error or if -h is given we call the function help:
[ -z "$1" ] && help
[ "$1" = "-h" ] && help

# send the escape sequence to change the xterm titelbar:
echo -e "33]0;$107"

执行xtitlebar或xtitlebar -h均出现如下错误:

cat: change: No such file or directory
cat: the: No such file or directory
cat: name: No such file or directory
cat: of: No such file or directory
cat: an: No such file or directory
cat: xterm,gnome-terminal: No such file or directory
cat: or: No such file or directory
cat: kde: No such file or directory
cat: konsole: No such file or directory
./xtitlebar: line 8: USAGE:xtitlebar: command not found
./xtitlebar: line 10: OPTION:-h: command not found
./xtitlebar: line 12: EXAMPLE:xtitlebar: command not found
./xtitlebar: line 14: HELP: command not found

请教解答错误在哪?.如何制作脚本的help?      
可以直接用echo      
使用echo的好处在于可以控制输出文字的颜色,用来强调。      
再次建议你读《LINUX与UNIX SHELL编程指南》。
第15章 引号。      
用echo是可以,可是我想知道用cat怎么实现help()函数的效果.      
那你就把你要echo的东西写到一个文件里,再用cat不就行了。      
那么我上面的脚本错在什么地方呢?我是按照论坛中的一篇shell编程文章输入的.按理说应该没有错的.      
实际这个脚本是这样的:
[CODE]

#!/bin/sh
# vim: set sw=4 ts=4 et:

help()
{
    cat <<HELP
xtitlebar -- change the name of an xterm, gnome-terminal or kde konsole

USAGE: xtitlebar [-h] "string_for_titelbar"

OPTIONS: -h help text

EXAMPLE: xtitlebar "cvs"

HELP
    exit 0
}

# in case of error or if -h is given we call the function help:
[ -z "$1" ] && help
[ "$1" = "-h" ] && help

# send the escape sequence to change the xterm titelbar:
echo -e "33]0;$107"
#
[/CODE]

在前面的“cat <<HELP”和后面的“HELP”是为cat的内容设置起止点,没有特殊意义的,完全可以把HELP换成别的词,但一定要一样。