tmp: A simple temp directory wrapper
This commit is contained in:
parent
960fb298ff
commit
88c3fc575b
24
tmp
Executable file
24
tmp
Executable file
@ -0,0 +1,24 @@
|
||||
#! /bin/bash
|
||||
#
|
||||
# tmp.bash
|
||||
# Copyright (C) 2018 salt <salt@lap-th-e560-0>
|
||||
#
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
## Define variables
|
||||
name="$(basename "$0" .sh)"
|
||||
tmpdir="$(mktemp -d)"
|
||||
## Define functions
|
||||
function log() {
|
||||
[ -z ${1+x} ] && return 1
|
||||
printf "${name}: $1\n"
|
||||
}
|
||||
## Do the do
|
||||
log "This folder will be removed when this shell exits"
|
||||
(
|
||||
cd "${tmpdir}"
|
||||
$SHELL
|
||||
)
|
||||
rm -rf "${tmpdir}"
|
||||
|
Loading…
Reference in New Issue
Block a user