From b544687f0fdf5012910f14c0fb7171843204a55c Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Mon, 27 Feb 2023 23:27:26 -0500 Subject: [PATCH] Fill out stub of make_working_dir function --- utils/lib_utils.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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