想很久不知道怎么命名这个题目,姑且就这样吧,应该能表达我的意思了。
主要实现:
(1)shell命令根据不同的option返回不同执行的功能,如ls -l和ls -a会输出不同结果。
(2)在运行过程中可以读取参数
(3)“提示选择”,罗列所有可选项,让调用者选择
(4)适当地给出“help”帮助信息
这里先说明几点
(1)select:选择提示使用的是bash中的扩展改功能select,linux下默认是bash,unix中就必须显示指定"#!/bin/bash"
(2)shift:用于把参数逐个处理掉,shfit n 把前面n个参数去掉,后面参数前移
(3)[expr]和[[expr]]:若能保证表达式中变量不会为空,两者效果都是一样的,但是如果有变量为空,如[$1=$className ]中$1为空,结果就是[=$className ],是“["和$className比较,就会报语法错误,因为少了一个"["。
根据这些参数,我们会有不同的运行结果,这里只是简单的把类名或方法名按指定的次数输出显示,具体运行方法视需求而定,过程是一样的。
#!/bin/bash
classNames="Calendar DeskClock Note FileExplorer"
methodNames="CalendarMethod DeskClockMethod NoteMethod FileExplorerMethod"
#the running type,0 for class,1 for method,defalut -1
type=-1
#the runtest command
#commandTmp="adb shell uiautomator runtest SanityAccessoryTestCase.jar"
commandTmp="echo"
help()
{
cat <<HELP
NAME:dis - display the gived className or methodName
USAGE:dis [-c className] [-c] [-m methodName] [-m] [-n num] [-h ]
ExAMPLE:dis -c Calendar -n 3
dis -m CalendarMethod -n 3
dis -c
dis -h
dis
NOTE:can not use -c and -m at the same time!
HELP
exit 0
}
testAll()
{
echo $classNames $methodNames
exit 0
}
#list and choose the name for testing
listClassName()
{
echo "input the className"
select className in $classNames;do
break
done
}
#list and choose the name for testing
listMe
主要实现:
(1)shell命令根据不同的option返回不同执行的功能,如ls -l和ls -a会输出不同结果。
(2)在运行过程中可以读取参数
(3)“提示选择”,罗列所有可选项,让调用者选择
(4)适当地给出“help”帮助信息
这里先说明几点
(1)select:选择提示使用的是bash中的扩展改功能select,linux下默认是bash,unix中就必须显示指定"#!/bin/bash"
(2)shift:用于把参数逐个处理掉,shfit n 把前面n个参数去掉,后面参数前移
(3)[expr]和[[expr]]:若能保证表达式中变量不会为空,两者效果都是一样的,但是如果有变量为空,如[$1=$className ]中$1为空,结果就是[=$className ],是“["和$className比较,就会报语法错误,因为少了一个"["。
根据这些参数,我们会有不同的运行结果,这里只是简单的把类名或方法名按指定的次数输出显示,具体运行方法视需求而定,过程是一样的。
有什么意见或建议大家可以提出
#!/bin/bash
classNames="Calendar DeskClock Note FileExplorer"
methodNames="CalendarMethod DeskClockMethod NoteMethod FileExplorerMethod"
#the running type,0 for class,1 for method,defalut -1
type=-1
#the runtest command
#commandTmp="adb shell uiautomator runtest SanityAccessoryTestCase.jar"
commandTmp="echo"
help()
{
cat <<HELP
NAME:dis - display the gived className or methodName
USAGE:dis [-c className] [-c] [-m methodName] [-m] [-n num] [-h ]
ExAMPLE:dis -c Calendar -n 3
dis -m CalendarMethod -n 3
dis -c
dis -h
dis
NOTE:can not use -c and -m at the same time!
HELP
exit 0
}
testAll()
{
echo $classNames $methodNames
exit 0
}
#list and choose the name for testing
listClassName()
{
echo "input the className"
select className in $classNames;do
break
done
}
#list and choose the name for testing
listMe