I have a bunch of general cleanup code that should be executed whenever any bash script ends, regardless of whether it exited normally or was interrupted. I decided that for this I used the pseudo signal trap "..." EXIT .
In addition to the usual cleanup tools, there is also one part of a specific cleanup that should only be performed if the script completes normally. I thought I could call this if the "trap" block checks the variable, for example:
 #!/bin/bash done=false; trap "{ #generic cleanup code goes here. if $done then #cleanup to be done only on completion goes here. echo Test; fi }" EXIT  
However, this does not work. Executing the following code will never repeat the "Test". Adding an explicit call to exit after done=true; nothing changes. What am I missing?
Hurrah!
Zac b  source share