29 lines
755 B
Plaintext
29 lines
755 B
Plaintext
|
function zshlibs_ensure()
|
||
|
{
|
||
|
target="${2}"
|
||
|
typ="${1}"
|
||
|
if ! test -e "${target}"
|
||
|
then
|
||
|
zshlibs_log zshlibs_ensure "creating '${target}' ($typ) …"
|
||
|
case $typ in
|
||
|
-d)
|
||
|
mkdir -p "${target}" \
|
||
|
|| zshlibs_log $0 "unable to create directory '${target}'" \
|
||
|
&& return 2
|
||
|
;;
|
||
|
-f)
|
||
|
touch "${target}" \
|
||
|
|| zshlibs_log $0 "unable to create file '${target}'" \
|
||
|
&& return 2
|
||
|
esac
|
||
|
zshlibs_log zshlibs_ensure "target '${target}' created"
|
||
|
elif test "${typ}" "${target}"
|
||
|
then
|
||
|
zshlibs_log zshlibs_ensure "target '${target}' ($typ) present"
|
||
|
return 0
|
||
|
else
|
||
|
zshlibs_log zshlibs_ensure "target '${target}' already exists and it is not a directory"
|
||
|
return 1
|
||
|
fi
|
||
|
}
|