Selaa lähdekoodia

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.
Alexey Shpakovsky 11 vuotta sitten
vanhempi
commit
93808a0254
1 muutettua tiedostoa jossa 1 lisäystä ja 0 poistoa
  1. 1 0
      bb.sh

+ 1 - 0
bb.sh

@@ -784,6 +784,7 @@ tags_in_post() {
 # Arguments are tags
 # Arguments are tags
 # Prints one line with space-separated tags to stdout
 # Prints one line with space-separated tags to stdout
 posts_with_tags() {
 posts_with_tags() {
+    [ $# -lt 1 ] && return
     tag_files="$(echo "$@" | sed "s/\S\+/tag_&.html/g")"
     tag_files="$(echo "$@" | sed "s/\S\+/tag_&.html/g")"
     sed -n '/^<h3><a class="ablack" href="[^"]*">/{s/.*href="\([^"]*\)">.*/\1/;p}' $tag_files
     sed -n '/^<h3><a class="ablack" href="[^"]*">/{s/.*href="\([^"]*\)">.*/\1/;p}' $tag_files
 }
 }