This function has been broken since it was updated to work with the
"stopped" state (probably commit
67c5bfb5f02c9d45a32d976021ede4fb2174dfe9). Although ${var#:*:0}
removes the shortest matching prefix of $var, '*' can match substrings
that include ':' if '0' isn't where you expect. So we were making
unexpected matches and incorrectly returning true for some cases.
Signed-off-by: Martin Schwenke <martin@meltin.net>
{
read x
while read line ; do
- [ "${line#:${pnn}:*:${bits}}" != "$line" ] && return 0
+ # This needs to be done in 2 steps to avoid false matches.
+ local line_bits="${line#:${pnn}:*:}"
+ [ "$line_bits" = "$line" ] && continue
+ [ "${line_bits#${bits}}" != "$line_bits" ] && return 0
done
return 1
} <<<"$out" # Yay bash!