# shellcheck disable=SC2064 trap "cleanup '$SCR_IMG'" EXIT
The command passed to `trap` is evaluated normally, so variable expansions do take place.
trap 'cleanup "$SCR_IMG"' EXIT
Alternatively, if you're using a modern bash (this probably won't work on a mac by default), then this is an option too:
trap "cleanup ${SCR_IMG@Q}" EXIT
The command passed to `trap` is evaluated normally, so variable expansions do take place.
Will behave correctly, and the expansion of SCR_IMG won't be susceptible to issues relating to unquoted shell characters.Alternatively, if you're using a modern bash (this probably won't work on a mac by default), then this is an option too: