From 5a36c277ba5eb96a963c71295339dc11df734ac9 Mon Sep 17 00:00:00 2001 From: levasseur Date: Mon, 4 Oct 2021 17:52:57 +0200 Subject: [PATCH] added isdirempty and embrio of patchfile --- lib/filefct.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/filefct.sh b/lib/filefct.sh index effefb8..ce8e9a3 100644 --- a/lib/filefct.sh +++ b/lib/filefct.sh @@ -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