From 93808a0254055506918c278ea796508ede8a5075 Mon Sep 17 00:00:00 2001 From: Alexey Shpakovsky Date: Sat, 28 Jun 2014 17:17:30 +0200 Subject: [PATCH 1/2] don't invoke sed when no tag given the bug was that sed was expecting file content on stdin when didn't receive any filename, and script was "frozen" when someone tried to edit a post without any tags. --- bb.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bb.sh b/bb.sh index 1694830..cb37fa0 100755 --- a/bb.sh +++ b/bb.sh @@ -784,6 +784,7 @@ tags_in_post() { # Arguments are tags # Prints one line with space-separated tags to stdout posts_with_tags() { + [ $# -lt 1 ] && return tag_files="$(echo "$@" | sed "s/\S\+/tag_&.html/g")" sed -n '/^

/{s/.*href="\([^"]*\)">.*/\1/;p}' $tag_files } From a5a196773a1e726da18fd2e76122467b58816283 Mon Sep 17 00:00:00 2001 From: Alexey Shpakovsky Date: Sat, 28 Jun 2014 17:18:24 +0200 Subject: [PATCH 2/2] suppress error messages and don't enter for loop when no tag files exist --- bb.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bb.sh b/bb.sh index cb37fa0..d9b852c 100755 --- a/bb.sh +++ b/bb.sh @@ -720,7 +720,7 @@ all_tags() { echo "

$template_tags_title

" >> "$contentfile" echo "
    " >> "$contentfile" - for i in ./$prefix_tags*.html; do + for i in $(ls ./$prefix_tags*.html 2>/dev/null || echo ''); do echo -n "." nposts="$(grep -c "<\!-- text begin -->" $i)" tagname="$(echo $i | cut -c $((${#prefix_tags}+3))- | sed 's/\.html//g')" @@ -837,7 +837,7 @@ rebuild_tags() { rm "$tmpfile" done # Now generate the tag files with headers, footers, etc - for i in $(ls -t ./$prefix_tags*.tmp.html); do + for i in $(ls -t ./$prefix_tags*.tmp.html 2>/dev/null || echo ''); do tagname="$(echo $i | cut -c $((${#prefix_tags}+3))- | sed 's/\.tmp\.html//g')" create_html_page "$i" "$prefix_tags$tagname.html" yes "$global_title — $template_tag_title \"$tagname\"" rm "$i"