diff --git a/tmp b/tmp index 4dcb2c4..2470313 100755 --- a/tmp +++ b/tmp @@ -8,6 +8,7 @@ # Define variables name="$(basename "$0" .sh)" +tmpdirtemplate="XXXXXX" tmpdir="$(mktemp -d)" # Verify them @@ -50,7 +51,7 @@ EOF esac done -# Copy in template directory +# Validate $1 if [ -n "$1" ]; then # Source in XDG dirs, if they exist userdirs="${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs" @@ -68,6 +69,14 @@ if [ -n "$1" ]; then exit 4 fi log "Using template \"$1\"" + tmpdirtemplate="$1.$tmpdirtemplate" +fi + +# Make our directory +tmpdir="$(mktemp -dt "tmp.$tmpdirtemplate")" + +# Copy in template directory +if [ -n "$1" ] && [ -n "$copydir" ] && [ -n "$tmpdir" ]; then cp -r "$copydir"/* "$tmpdir" unset copydir fi