diff --git a/utils/lib_utils.sh b/utils/lib_utils.sh index d2c3468..52fad3f 100644 --- a/utils/lib_utils.sh +++ b/utils/lib_utils.sh @@ -41,7 +41,21 @@ set -o nounset # Treat unset variables as an error # PARAMETERS: # RETURNS: The path to the working directory #------------------------------------------------------------------------------- -function make_working_dir { echo; } +function make_working_dir { + # the directory of the script + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + + # the temp directory used, within $DIR + # omit the -p parameter to create a temporal directory in the default location + WORK_DIR=`mktemp -d -p "$DIR"` + + # check if tmp dir was created + if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then + echo "Could not create temp dir" + exit 1 + fi + echo $WORK_DIR + } #--- FUNCTION ---------------------------------------------------------------- # NAME: clean_working_dir