fun(){ host=$1 return ping -c1 $host >/dev/null 2>&1 } fun2(){ host=$1 ping -c1 $host >/dev/null 2>&1 return $? } fun hpcs09 echo "fun return is: "$? fun2 hpcs09 echo "fun2 return is: "$?
[quote=引用 2 楼 wesleyflagon 的回复:] return [n] Causes a function to exit with the return value specified by n. return的参数是一个数值, 不是一个命令
return [n] Causes a function to exit with the return value specified by n. return的参数是一个数值, 不是一个命令
.... fun(){ host=$1 return ping -c 1 $host } 你这样试试就知道为什么了,这是执行函数报错了。。。 然后你把输出重定向了,就看不到错误了~~
23,120
社区成员
74,507
社区内容
加载中
试试用AI创作助手写篇文章吧