- 论坛徽章:
- 0
|
这是运行时的错误提示
[root@linux ~]# func
./func: line 12: syntax error near unexpected token `then'
./func: line 12: `then'
程序如下
#!/bin/bash
#func
char_name()
#chanr_name
#to call:char_name string
#check if $1 dose indeed contain only characters a-z,A-Z
{
#assign the argument across to new variable
_LETTERS_ONLY=$1
_LETTERS_ONLY=`echo $1|awk '{if($0~/[^a-zA-Z]/) print "1"}'`
if["$_LETTERS_ONLY" !=""]
then
#oops error
return 1
else
#contains only chars
return 0
fi
}
name_error()
#display an error message
{
echo "$@ contains errors,it must contain only letters"
}
while :
do
echo -n "what's your first name:"
read F_NAME
if char_name $F_NAME
then
#all ok breakout
break
else
name_error $F_NAME
fi
done
感谢不厌其烦的为我解答这种菜鸟问题 |
|