tmp: Code cleanup
This commit is contained in:
parent
cc2ca23837
commit
e6be305258
9
tmp
9
tmp
@ -14,7 +14,10 @@ tmpdir="$(mktemp -d)"
|
|||||||
# Define functions
|
# Define functions
|
||||||
function log() {
|
function log() {
|
||||||
[ -z ${1+x} ] && return 1
|
[ -z ${1+x} ] && return 1
|
||||||
printf "${name}: $1\n"
|
# shellcheck disable=1117
|
||||||
|
printf "%b: %s\n" \
|
||||||
|
"$name" \
|
||||||
|
"$1"
|
||||||
}
|
}
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
rm -rf "${tmpdir}"
|
rm -rf "${tmpdir}"
|
||||||
@ -23,8 +26,8 @@ trap "cleanup" EXIT
|
|||||||
# Do the do
|
# Do the do
|
||||||
log "This folder will be removed when this shell exits"
|
log "This folder will be removed when this shell exits"
|
||||||
(
|
(
|
||||||
cd "${tmpdir}"
|
cd "${tmpdir}" || exit 50
|
||||||
$SHELL
|
exec "$SHELL"
|
||||||
)
|
)
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user