usepreferredadapter elif [[ $adapter == "2" ]]; then echo --6ren">
gpt4 book ai didi

linux - 如何重定向到代码中更靠后的函数?

转载 作者:太空宇宙 更新时间:2023-11-04 09:58:09 25 4
gpt4 key购买 nike

if [[ $adapter == "1" ]]; then

LINE 66 > usepreferredadapter

elif [[ $adapter == "2" ]]; then

echo -e "\e[0mI'm sorry you do not own the requirements to proceed!"
echo "Try using the adapter that's build in , into your computer (not working on Virtualbox or VMware)"
echo -e "\e[31mNote that build in adapters are over all bad for hacking!\e[0m"
echo "Script will exit!"
exit



else

echo "Invalid input!"
echo "Script will exit!"
exit


fi

LINE 89 > function usepreferredadapter(){

在第 66 行中,我希望将用户重定向到第 89 行中的函数,我该怎么做(如果可能的话)?

最佳答案

为了避免这种行为,我建议您将所有代码放在一个主函数中,以便在您需要时加载所有内容

例如

#!/bin/bash
main() {
if [[ $adapter == "1" ]]; then
usepreferredadapter
elif [[ $adapter == "2" ]]; then
...
fi
}

function usepreferredadapter(){
...
}

main "$@"

这样,只要在脚本底部调用 main 方法,在哪里定义方法都没有关系

关于linux - 如何重定向到代码中更靠后的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58468492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com