I'm getting some strange behavior from bash witch I cannot understand. I've tryed to google this problem some times but with no luck.
I just copy/paste a small shell script .. (It a outcome of a bigger one - but gives a picture of the problem).
- Code: Select all
[# ========= check_if_burn() - Checks whatever if a iso allready is burned out =
ls | while read f
if [ "$ext" = "SUCCESS" ]
echo "There was a success file: $f"
was_ok=1 ### Why wont this change?
} # check_if_burn end
echo "Exitcode was:$?"
The strange part is the following.
I will get a echo output while having a success file - but the variable was_ok never changes (or gets set to 0?)
When i set the variable in the top of the function - it will change, and if I do it in the buttom of the script it will change. Its -only- while its into some sort of loop its giving me trouble (I even tried with "for" and "until").
So - trouble is - why can I set a variable in a loop?
looking forward to some great reply s - this has been nagging me