From 132f649d933343c45e71d6062814a9543ab2a971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig-=C3=98rjan=20Smelror?= Date: Wed, 31 Jan 2024 21:04:19 +0100 Subject: [PATCH] _list_blog: Rewrite --- qsgen2 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/qsgen2 b/qsgen2 index 1289b9c..f488edc 100755 --- a/qsgen2 +++ b/qsgen2 @@ -169,14 +169,16 @@ export blogdate=$( date +%a-%Y-%b-%d ) # Let's create arrays of all the files we'll be working on function _list_blog() { - # Check if there are any .blog files in the blog directory + local debug=false local blog_files=(blog/*.blog) - if [[ ! -f ${blog_files[1]} ]]; then - if (${debug}); then _msg debug "_blog_cache: No blog files found."; fi + + # Check if array is empty + if (( ${#blog_files[@]} == 0 || ! -f ${blog_files[1]} )); then + if (${debug}); then _msg debug "_list_blog: No blog files found."; fi return else - ls -1btar blog/*.blog | while read -r file; do - blogs_file_array+=($file) + for file in blog/*.blog; do + blogs_file_array+=("$file") done fi }