From 181f8a4dcd409a0a83e80bebe9f5c4dde360e48b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig-=C3=98rjan=20Smelror?= Date: Wed, 31 Jan 2024 21:08:08 +0100 Subject: [PATCH] _list_blog: Another rewrite --- qsgen2 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/qsgen2 b/qsgen2 index 0ef70e3..56d3f69 100755 --- a/qsgen2 +++ b/qsgen2 @@ -170,17 +170,20 @@ export blogdate=$( date +%a-%Y-%b-%d ) function _list_blog() { local debug=false - # local blog_files=(blog/*.blog) - # Check if array is empty - if [[ -z "$(ls -A blog/*.blog 2>/dev/null)" ]]; then + # Temporarily set null_glob for this function + setopt local_options null_glob + + # Check if there are any .blog files in the blog directory + local blog_files=(blog/*.blog) + if (( ${#blog_files} == 0 )); then if (${debug}); then _msg debug "_list_blog: No blog files found."; fi return - else - for file in blog/*.blog; do - blogs_file_array+=("$file") - done fi + + for file in blog/*.blog; do + blogs_file_array+=("$file") + done } # BLOG CACHE