From 04e634bf4806100296585f17fa6a764a8f80ec72 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Fri, 8 Feb 2008 15:05:52 +0000 Subject: [PATCH] dir2org.zsh: two small bug fixes --- CONTRIB/scripts/dir2org.zsh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CONTRIB/scripts/dir2org.zsh b/CONTRIB/scripts/dir2org.zsh index 27e34a566..5fe983b5d 100755 --- a/CONTRIB/scripts/dir2org.zsh +++ b/CONTRIB/scripts/dir2org.zsh @@ -30,9 +30,12 @@ function scan_and_populate { headline ${depth} "${dir}" + # if there is no files in dir then just move on + [[ $(ls "${dir}" | wc -l) -eq 0 ]] && return + (( depth += 1 )) - for f in $(ls -d "${dir}"/* 2>/dev/null); do + for f in $(ls -d "${dir}"/*); do if [ -d "${f}" ]; then scan_and_populate ${depth} "${f}" else @@ -40,7 +43,7 @@ function scan_and_populate { fi done - let "depth -= 1" + (( depth -= 1 )) } function main {