There are several issues in _queue_contains(), causing the
queue_put_unique() function to hang (waiting for input from stdin) or
add duplicate items to the queue.
This commit addresses these issues so that queue_put_unique() does not
hang or add duplicate items.
local item="$2"
local data
- local qdata
+ local qitem
data=$(_queue_get_data "$queue")
- while read -r qdata; do
- if [[ "$qdata" == "$data" ]]; then
+ if ! [ -f "$data" ]; then
+ return 1
+ fi
+
+ while read -r qitem; do
+ if [[ "$qitem" == "$item" ]]; then
return 0
fi
- done
+ done < "$data"
return 1
}