【发布时间】:2018-11-29 15:33:13
【问题描述】:
return 语句错误:urn: can only `return' from a function or sourced script in shell script 我的脚本.sh
#!/bin/bash
if [ $# -ne 2 ]
then
echo "Incorrect Usage : Arguments mismatch."
return 2
fi
mv $1 $2
return 0
当我尝试运行时
sh myscript.sh
Incorrect Usage : Arguments mismatch.
myscript.sh.sh: line 5: return: can only `return' from a function or sourced script
如何解决这个错误?
【问题讨论】:
-
这听起来像是 XY 问题。如果您想知道您的脚本是sourced 还是executed,this SO question 为您提供了一些答案。
标签: linux bash shell operating-system