我为什么运行如下程序会提示该错误
#!/bin/sh
help()
{
cat << HELP
This is a generic command line parser demo.
USAGE EXAMPLE: cmdparser -l hello -f -- -somefile1 somefile2
HELP
exit 0
}
while [ -n "$1" ]; do
case $1 in
-h) help;shift 1;; # function help is called
-f) opt_f=1;shift 1;; # variable opt_f is set
-l) opt_l=$2;shift 2;; # -l takes an argument -> shift by 2
--) shift;break;; # end of options
-*) echo "error: no such option $1. -h for help";exit 1;;
*) break;;
esac
done
echo "opt_f is $opt_f"
echo "opt_l is $opt_l"
echo "first arg is $1"
echo "2nd arg is $2"
我运行就提示 Syntax error: end of file unexpected (expecting "}")
求教个脚本运行问题
-
- 帖子: 7
- 注册时间: 2008-10-11 19:18
- xiooli
- 帖子: 6956
- 注册时间: 2007-11-19 21:51
- 来自: 成都
- 联系:
Re: 求教个脚本运行问题
我运行没有错误阿。
-
- 帖子: 7
- 注册时间: 2008-10-11 19:18
Re: 求教个脚本运行问题
我也不知道为什么,总是出现那个错误,是不是系统有什么错误呀xiooli 写了:我运行没有错误阿。
-
- 帖子: 43
- 注册时间: 2008-08-17 6:09
Re: 求教个脚本运行问题
while [ -n "$1" ]; do????????
你是不是想
while [ -n "$1" ]
do
啊?
没有那个分号吧??????/
你是不是想
while [ -n "$1" ]
do
啊?
没有那个分号吧??????/
-
- 帖子: 7
- 注册时间: 2008-10-11 19:18
Re: 求教个脚本运行问题
似乎是因为我写第二个HELP没顶格,真邪门
- solcomo
- 帖子: 2838
- 注册时间: 2007-04-25 13:12
Re: 求教个脚本运行问题
就是要顶格的
♜♞♝♛♚♝♞♜
♟♟♟♟♟♟♟♟
♙♙♙♙♙♙♙♙
♖♘♗♕♔♗♘♖
☠☯⚔☣☦☃
☹☻☪☭☬⚖⚛⚜
ℜℳℬ™ ℋℯℓ℘ ℳℭ
sƂɐʍ рǀɹoʍ əɥʇ oS
♟♟♟♟♟♟♟♟
♙♙♙♙♙♙♙♙
♖♘♗♕♔♗♘♖
☠☯⚔☣☦☃
☹☻☪☭☬⚖⚛⚜
ℜℳℬ™ ℋℯℓ℘ ℳℭ
sƂɐʍ рǀɹoʍ əɥʇ oS
-
- 帖子: 43
- 注册时间: 2008-08-17 6:09
Re: 求教个脚本运行问题
好像是这样子的......
也没有怎么注意那一个地点.
这种程序好难找错误哦.....
也没有怎么注意那一个地点.
这种程序好难找错误哦.....