-
-
Save zapashcanon/5921e531737b69d67fdaa7c4317c0ba6 to your computer and use it in GitHub Desktop.
Go-like defer 'keyword' for shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
DEFER= | |
defer() { | |
DEFER="$*; ${DEFER}" | |
trap "{ $DEFER }" EXIT | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment