说我有这个功能:
function run_sanity_check(){
echo -e "This is test level 1\n"
echo -e "This is test level 2\n"
}
和另一个功能:
function run_test(){
... environment setup routine runs here
echo -e "Running tests...\n"
run_sanity_check --> this would be my call for the function above
}
当我打电话给" run_test"我收到此错误: 功能:未找到
感谢任何帮助。
答案 0 :(得分:1)
正如Brian的评论所提到的,您需要使用function
或()
,而不是两者都使用。
以下两项均有效,基于the documentation。
function run_sanity_check{
echo -e "This is test level 1\n"
echo -e "This is test level 2\n"
}
run_sanity_check(){
echo -e "This is test level 1\n"
echo -e "This is test level 2\n"
}
以下脚本打印预期输出。
run_sanity_check(){
echo -e "This is test level 1\n"
echo -e "This is test level 2\n"
}
run_test(){
echo -e "Running tests...\n"
run_sanity_check
}
run_test