From 7738c6a67d453568b0806e077537bbedeeed054b Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Mon, 2 Jan 2012 17:45:09 +0200 Subject: [PATCH] bin/mktmpdir tweaks The fallback case of building in a brother directory moved from the last line of code to the first one becoming more explicit along the way. Support for slash-containing argument (being a tmpdir name template prefix) has been added. --- bin/mktmpdir | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/mktmpdir b/bin/mktmpdir index 4dc2659c..ca70468b 100755 --- a/bin/mktmpdir +++ b/bin/mktmpdir @@ -2,7 +2,7 @@ # analyze free space, preferring tmpfs over really many gigaz # hope there aren't spaces in RM's $HOME are they? -DIRS="$TMP $TMPDIR $HOME/hasher /tmp /var/tmp" +DIRS="$TMP $TMPDIR $HOME/hasher /tmp /var/tmp .." MINSIZE=262144 # face control criterion # pick existing, writeable, >256M free space dirs @@ -25,5 +25,7 @@ choose_tmpdir() { | cut -f2 -d' ' } -DIR="`choose_tmpdir`" -mktemp -d "${1:-tmpdir}.XXXXXXX" --tmpdir="${DIR:-`realpath ..`}" +DIR="`choose_tmpdir`/`dirname "$1"`" +NAME="`basename "${1:-tmpdir}"`" +mkdir -p "$DIR" # in case $1 contains slash(es) +mktemp -d "$NAME.XXXXXXX" --tmpdir="${DIR%/.}"