add more error checking

This commit is contained in:
2026-07-24 14:50:46 -05:00
parent 303608172f
commit 2bf8241293
+20 -5
View File
@@ -109,8 +109,14 @@ get_file() {
echo " to \"${dest_file}\"." >&2
exit 4
fi
chown "${dest_file_ownership}" "${dest_file}"
chmod "${dest_file_permissions}" "${dest_file}"
if ! chown "${dest_file_ownership}" "${dest_file}" ; then
echo "ERROR - Unable to change ownership of \"${dest_file}\" to \"${dest_file_ownership}\"" >&2
exit 4
fi
if ! chmod "${dest_file_permissions}" "${dest_file}" ; then
echo "ERROR - Unable to change permissions of \"${dest_file}\" to \"${dest_file_permissions}\"" >&2
exit 4
fi
}
# $directory $directory_ownership $directory_permissions
@@ -121,9 +127,18 @@ create_directory() {
directory_ownership ="${2}"
directory_permissions="${3}"
mkdir -p "${directory}"
chown "${directory_ownership}" "${directory}"
chmod "${directory_permissions}" "${directory}"
if ! mkdir -p "${directory}" ; then
echo "ERROR - Unable to create directory \"${directory}\"" >&2
exit 5
fi
if ! chown "${directory_ownership}" "${directory}" ; then
echo "ERROR - Unable to change ownership of \"${directory}\" to \"${directory_ownership}\"" >&2
exit 5
fi
if ! chmod "${directory_permissions}" "${directory}" ; then
echo "ERROR - Unable to change permissions of \"${directory}\" to \"${directory_permissions}\"" >&2
exit 5
fi
}
# $command_line