在谷歌群组中问过这个问题,但我看到以前在这里问过类似的问题,所以我也在这里问过。这似乎是一个范围界定问题,但据我所知,该变量是全局的。
统计的退出代码始终为零。
谢谢。
ksh -c "exit_code=0;
# Get a list of sql files and interate through them to do certain work on a DB.
find ./sql_email_reports -maxdepth 1 -type f -print | while read line;
do echo \"Report = \" \${line};
#Now do some sql work on a DB based on the sql file as given by $line.
#and if the work to the DB fails for some reason, send back a return code greater than zero.
rc=\$?;
# Test the incrementation of exit_code by setting rc, which should increment exit_code for every file found in directory.
rc=1
echo \"rc = \" \${rc};
(( exit_code+=rc ));
echo \"Exit Code =\" \${exit_code};
done;
enter code here
# For some reason, the tallied exit_code is not what it is within the while loop, it is still zero
echo \"Tallied exit_code = \" \${exit_code};
(( exit_code > 0 )) && exit 1;
exit 0;"