bash在脚本中调用嵌套函数

时间:2017-05-25 12:49:29

标签: bash

如果用户选择为bash,我正在尝试调用y函数。在下面,函数execute是大约6000行的脚本,可以执行各种操作。 execute函数运行并完成后,backup函数执行调用run。系统会提示用户提供additional功能和n响应中的问题,如果答案是“' y'然后调用函数execute。如果答案是n,则调用函数remove

目前,脚本在不到一秒的时间内完成,并且没有创建新的文件或文件夹(脚本应该这样做)。如果一切正常,则需要约3个小时。我不确定我是否正确地调用了这个或者是否有更好的方法。

execute() {
....
....
....
....
backup  # starts the nested functions
}

backup() {
# move folder to backup
mv -v /home/cmccabe/Desktop/NGS/API/$filename /media/cmccabe/"My Book Western Digital"/ClinicalRuns; run
}

remove() {
# cleanup s5_files folder (downloads,patient,plugin,pdf)
rm /home/cmccabe/s5_files/downloads/combine
}

run() {
printf "\n\n"
printf "The process is complete, are there additional?  Y/N "; read match_choice

case "$match_choice" in
    [yY]) execute ;;
    [nN]) remove; printf "Goodbye! "; sleep 2 && exit ;;
esac
}

0 个答案:

没有答案