added isdirempty and embrio of patchfile

This commit is contained in:
levasseur
2021-10-04 17:52:57 +02:00
parent 169f2f520a
commit 5a36c277ba

View File

@@ -108,4 +108,30 @@ installfile()
}
export -f installfile
# ------------------------------------------------------------------------------
# determine if a directory is empty
isdirempty()
{
dir=$1
if [[ ! -d $dir ]]; then
return 0
fi
nbfiles=$(ls -a1 $dir | egrep -v '^.$|^..$' | wc -l)
if [[ $nbfiles -eq 0 ]]; then
return 0
fi
return 1
}
# ------------------------------------------------------------------------------
# patch a file replacing all @var@ by the corresponding value in environment
patchfile()
{
: # todo
}
# EOF