Thursday, November 05, 2009

weired way to get return value

I guess shell is always weired. if you run a command in a subroutine in a
script, try return in the command field and then return $? in the
subroutine field. as what following shows .

function isRunnable()
{
typ=$1;
filename=$2;
day_a=$3;
day=${day_a:=''}
cat 'exe_seq_all.dat' | grep "$filename$day$" | while read line
do
arr=($line);
prework=${arr[0]};
if [ ! `grep -c " $prework " 'fin.dat' ` = 0 ]
then
return 0;
fi;
return 1;
done
return $?;

No comments: