bash sh return:只能从函数或源脚本中“返回”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50949252/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 16:57:12 来源:igfitidea点击:
sh return: can only `return' from a function or sourced script
提问by karthi keyan
return statement error:urn: can only `return' from a function or sourced script in shell scriptmyscript.sh
return 语句错误:urn:只能从 shell 脚本myscript.sh 中的函数或源脚本“返回”
#!/bin/bash
if [ $# -ne 2 ]
then
echo "Incorrect Usage : Arguments mismatch."
return 2
fi
mv
return 0
When i try to run
当我尝试跑步时
sh myscript.sh
sh myscript.sh
Incorrect Usage : Arguments mismatch.
myscript.sh.sh: line 5: return: can only `return' from a function or sourced script
how to fix that error ?
如何修复该错误?