我有函数 ShowJobHistory,它是从另一个调用的。在第一次调用这个函数时一切正常,它计算正确数量的参数,根据我的需要解析它们。但是在接下来的调用中,即使我指定了多个参数,此函数也会将它们视为一个,并且在解析它们后看起来( jb.RJBGID=12871 12873 12868 )。我的功能有什么问题?
ShowJobHistory () {
conditions=
argCount=$#
if [[ $argCount -ne 0 ]] then
if [[ $1 == [iI] && $argCount -eq 3 ]] then
if [[ $2 -lt $3 ]] then
conditions="( jb.RJBGID between $2 and $3 )"
else
conditions="( jb.RJBGID between $3 and $2 )"
fi
else
conditions="("
for nr in $@
do
conditions="${conditions} jb.RJBGID=${nr} or "
done
conditions=${conditions%or }
conditions=$conditions")"
fi
typeset query
下面的函数调用 ShowJobHistory。
ShowJobHistoryMenu () {
typeset jobID
save=
echo "Enter jobIDs"
read jobID?"Enter jobID: "
while [[ $save != [nNyY] ]]
do
read save?"Save output to file? [y/n]"
done
if [[ save = [yY] ]] then
ShowJobHistory $jobID | tee $TRACEDIR/output.txt
else
ShowJobHistory $jobID
fi
}