home · contact · privacy
To feed generator, add handler for case of empty blog.
[redo-blog] / processor / feed.xml.do
index 19ba026d3589d30c0fefab2c82e0562e4358c376..0bc7318b0dc881bd094b81a17254d1977a5d48a8 100644 (file)
@@ -47,7 +47,11 @@ for file in ./*.rst ./*.md; do
 done
 
 # Derive feed modification date from snippets.
-mod_dates=$(grep -hE "^<updated>" ./${metadata_dir}/*.feed_snippet | sed -E 's/<.?updated>//g')
+n_snippet_files=`ls -1 ./${metadata_dir}/*.feed_snippet 2>/dev/null | wc -l`
+if [ $n_snippet_files != 0 ]
+then
+  mod_dates=$(grep -hE "^<updated>" ./${metadata_dir}/*.feed_snippet | sed -E 's/<.?updated>//g')
+fi
 last_mod_unix=0
 for date in $mod_dates; do
   date_unix=$(date -u "+%s" -d "${date}")
@@ -60,8 +64,10 @@ printf "<updated>%s</updated>\n\n" "$lastmod_rfc3339"
 
 # Write feed entries.
 for file in ./${tmp_snippets_dir}/*; do
-  cat "${file}"
-  printf "\n"
+  if [ -e "$file" ]; then
+    cat "${file}"
+    printf "\n"
+  fi
 done
 rm -rf "$tmp_snippets_dir"