X-Git-Url: http://git.plutz.net/?p=serve0;a=blobdiff_plain;f=multitag.sh;h=8b60adebb1ac8e265866f00570c47d124c0ca9e3;hp=45798069f237adfab581e7bcbe7b9034de3168d2;hb=1902cbbff7f9728f303cdb5e3fc37b18eddff4db;hpb=e00c626003d48bbf2d41619ee5379e95dc43fa27 diff --git a/multitag.sh b/multitag.sh index 4579806..8b60ade 100644 --- a/multitag.sh +++ b/multitag.sh @@ -7,7 +7,8 @@ newtags='' for tn in $(seq 1 $(POST_COUNT tag)); do newtags="${newtags},$(POST tag $tn)" done -newtags="${newtags},$(POST newtag |tr -d '\r')" +newtags="${newtags},$(POST newtag |tr -d '\r' |tr '\n' ,)" +[ "$(POST op)" = del ] && deltags="$newtags" for select in $(seq 1 $(POST_COUNT select)); do file="$_DATA/$ITEM/$(POST select $select |PATH)" @@ -16,9 +17,19 @@ for select in $(seq 1 $(POST_COUNT select)); do read -r length width height tags comment fn <<-EOF $(meta_info "$file") EOF - - tags="$(UNSTRING "${tags#tags=}")" - tags="$(printf '%s\n' "${tags}" "${newtags}" |tr , '\n' |sort -u |tr '\n' , |STRING)" + tags="$(UNSTRING "${tags#tags=}" |tr , '\n')" + + if [ ! "$deltags" ]; then + tags="$(printf '%s\n' "${tags},${newtags}" \ + | tr , '\n' |sort -u |tr '\n' , \ + | STRING)" + else + detag="${deltags},"; while [ "$detag" ]; do + tags="$(printf '%s\n' "$tags" |grep -vxFe "${detag%%,*}")" + detag="${detag#*,}" + done + tags="$(printf '%s\n' "$tags" |sort -u |tr '\n' , |STRING)" + fi tags="${tags#,}"; tags="${tags%,}" if LOCK "$meta"; then