これはGoogleグループで質問しましたが、以前にここで尋ねられた同様の質問を見たので、ここでも質問します. これはスコーピングの問題のように思えますが、私が知る限り、変数はグローバルです。
集計された終了コードは常にゼロです。
ありがとう。
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;"