验证码:
function1(){
matchType=$1
if [[ $matchType == 'contains' ]];then
PID=`pgrep -f a`
elif [[ $matchType == 'exact' ]];then
PID=`pgrep -x a`
fi
if [[ $? -eq 0 ]];then
echo "process id fetched successful" // log echo
else
echo"process id fetched failed" // log echo
fi
echo "$PID" //return echo
}
function2()
{
output=$(function1 contains)
}
字符串
output变量的值是'process id fetched failed',而不是我在函数1中最后回显的PID
要求:它应该返回PID值到函数2
1条答案
按热度按时间u3r8eeie1#
你是说这个吗?
字符串
或者您要在何处记录?