From ef81f63036162794b2f64e0542c0ce2f743aed74 Mon Sep 17 00:00:00 2001 From: "Carlos M. Martinez" Date: Tue, 13 Feb 2024 11:33:47 -0500 Subject: [PATCH] Updated isWritable --- scripts/helper_functions.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/helper_functions.sh b/scripts/helper_functions.sh index 606655d9a..686e554f4 100644 --- a/scripts/helper_functions.sh +++ b/scripts/helper_functions.sh @@ -46,7 +46,17 @@ isReadable() { isWritable() { local path="$1" local return_val=0 - if ! [ -w "${path}" ]; then + # Directories may be writable but not deletable causing -w to return false + if [ -d "${path}" ]; then + temp_file=$(mktemp -q -p "${path}") + if [ -n "${temp_file}" ]; then + rm -f "${temp_file}" + else + echo "${path} is not writable." + return_val=1 + fi + # If it is a file it must be writable + elif ! [ -w "${path}" ]; then echo "${path} is not writable." return_val=1 fi