From 302bf4c180458c957295062da890b6b73f246bc9 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Tue, 5 Dec 2017 21:30:17 +0000 Subject: [PATCH] Handle writable-but-not-a-directory cases for writable OBJDIR check. Sponsored by: Dell EMC --- share/mk/src.sys.obj.mk | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/share/mk/src.sys.obj.mk b/share/mk/src.sys.obj.mk index efed181d5c7a..5ed92f16ebab 100644 --- a/share/mk/src.sys.obj.mk +++ b/share/mk/src.sys.obj.mk @@ -137,7 +137,10 @@ __objdir:= ${MAKEOBJDIR} # If the last component is a symlink then recurse on the new path. CheckAutoObj= \ DirIsCreatable() { \ - [ -w "$${1}" ] && return 0; \ + if [ -w "$${1}" ]; then \ + [ -d "$${1}" ] || return 1; \ + return 0; \ + fi; \ d="$${1}"; \ IFS=/; \ set -- $${d}; \ @@ -154,13 +157,16 @@ DirIsCreatable() { \ ret=0; \ DirIsCreatable "$${dir%/}" || ret=$$?; \ return $${ret}; \ + elif [ -e "/$${dir}$${d}" ]; then \ + return 1; \ else \ break; \ fi; \ fi; \ dir="$${dir}$${d}/"; \ done; \ - [ -w "$${dir}" ]; \ + [ -w "$${dir}" ] && [ -d "$${dir}" ] && return 0; \ + return 1; \ }; \ CheckAutoObj() { \ if DirIsCreatable "$${1}"; then \