Thanks for taking your time to write those examples.
Finally found some time to work through them.
1.
Can we say that there is no possibility to call a function inside an IF without forking?
The function has to run prior to the IF and the IF itself is only comparing return values or variables.
This is probably the same for while-loops?
What would be a workaround to avoid this fork?
while [[ $(hour_match) -eq 1 ]] #
do
Probably starting with "while [1 ]"
and calling the hour_match after the first loop-run?
2.
check_LockFile
hour_match
if [[ $? -eq 0 && $LockFile -eq 0 ]]
When doing it like this:
"$? -eq 0" is working only if the function was called in the prior line?
So comparing multiple return codes won't be possible? The second value has to be a variable?
3.
Edit:
I noticed you use the variables like:
if [[ ${HOUR_MATCHED_RC} -eq 0 && $lockfile -eq 0 ]]
while in the whole script the variables are within quotes.
if [[ "$hourMatch" -eq 0 && "$LockFile" -eq 0 ]]
Quotes = string, no quotes = integer?
If this is true, then I will have to stick either to the string-writing or to the integer-writing.
Then I would have to do:
if [[ "$?" -eq 0 && "$LockFile" -eq 0 ]]
or
if [[ $? -eq 0 && $LockFile -eq 0 ]]
Right?
4.
Conclusion:
While working with return codes seems pretty slight/slender it is not very transparent to the noob user.
Working with variables seems better especially if someone else is supposed to decipher it.