contrib: Fix early cleanup in recovery script

Currently, `mod_recovery_for_decryption.sh` tries to clean up
intermediate files using `trap "rm ${file}" RETURN` to delete the files
when the function returns.  This does not work correctly because
`common.sh` calls `shopt -s extdebug` which causes the `RETURN` trap to
be inherited by called functons.  Thus the first function invoked causes
the file to be removed on return.

Add a `cleanup_files` array whose members get deleted (if they exist) by
the `cleanup` function called by the `EXIT` trap.  This is not quite as
"clean" as using `RETURN`, but it works.

BUG=None
TEST=ran the script to verify the temp file was cleaned up

Change-Id: I8ca9d3aeb3a132abe8492968d8f510535992f49c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2805171
Tested-by: Ian Flanigan <flan@google.com>
Auto-Submit: Ian Flanigan <flan@google.com>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
1 file changed