You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scripts: use trap to make sure old files always restored
In this commit, we fix an issue I observed on my machine after updating
many command line/dev utilities.
I observed that if the script failed for w/e reason, then the old files
weren't properly restored.
The repro on my machine is something like:
1. Shutdown docker, make sure the daemon isn't accessible.
2. Run `mac sqlc`. The script should fail.
3. Observe that the files in your local working tree are still
altered.
We fix this by using the `trap` command, [which is basically like Go's
`defer`, but for bash
scripts](https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_12_02.html)!
0 commit comments