]> git.plutz.net Git - serve0/commitdiff
avoid orphaned close tag when tag list is empty
authorPaul Hänsch <paul@plutz.net>
Tue, 22 Feb 2022 18:48:13 +0000 (19:48 +0100)
committerPaul Hänsch <paul@plutz.net>
Tue, 22 Feb 2022 18:48:13 +0000 (19:48 +0100)
widgets.sh

index 23afd9d440ba6ffbf411faaffcd628f58634403d..df141e786cb3854cfff1bf2aa8f398f3e9de278e 100755 (executable)
@@ -230,7 +230,7 @@ w_delete(){
 }
 
 w_tagging(){
-  local tctag oldcat category tag
+  local tctag oldcat="" category tag
 
   cat <<-EOF
        [a href="#multitag" Add Tags / Remove Tags]
@@ -238,8 +238,6 @@ w_tagging(){
          [a href="#" X]
        EOF
 
-  oldcat="Tags"
-  printf '[fieldset [legend %s:][div .tagselect\n' "Tags"
   printf '%s\n' "$w_tags" \
   | while read tctag; do
     [ "$tctag" ] || continue
@@ -250,14 +248,14 @@ w_tagging(){
     && category="Tags"
 
     if [ "$category" != "$oldcat" ]; then
-      printf ']]'
+      [ "$oldcat" ] && printf ']]'
       printf '[fieldset [legend %s:][div .tagselect\n' "$category"
     fi
     printf '[label [checkbox "tag" "%s"] %s]\n' "$tctag" "$tag"
 
     oldcat="$category"
   done
-  printf ']]'
+  [ "$w_tags" ] && printf ']]'
 
   cat <<-EOF
          [fieldset [legend New:][textarea name=newtag\n]