|
From: | GNU bug Tracking System |
Subject: | bug#33972: closed (grep -vf <(<nothing>) filters all rows) |
Date: | Thu, 02 Jan 2020 09:05:02 +0000 |
Your message dated Thu, 2 Jan 2020 01:04:21 -0800 with message-id <address@hidden> and subject line grep -vf <(<nothing>) filters all rows has caused the debbugs.gnu.org bug report #33972, regarding grep -vf <(<nothing>) filters all rows to be marked as done. (If you believe you have received this mail in error, please contact address@hidden.) -- 33972: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=33972 GNU Bug Tracking System Contact address@hidden with problems
--- Begin Message ---Subject: grep -vf <(<nothing>) filters all rows Date: Fri, 4 Jan 2019 00:04:28 -0500 User-agent: SquirrelMail/1.4.22 I have to pre-check for an empty set before passing it to grep:
SAVED_RECORDs=($(sqlite3 -list -separator '/' files.db "SELECT FileName FROM Files WHERE ModTime > '2018-12-31'")) #Returns an empty set
NEW_RECs=($(ls * | grep -vf <(echo ${SAVED_RECORDs[@]} | tr ' ' '\n') #Returns an empty list because grep considers SAVED_RECORDs to be universal rather than null set
Workaround:
if [ ${#SAVED_RECORDs[@]} -gt 0 ]; then
NEW_RECs=($(ls * | grep -vf <(echo ${SAVED_RECORDs[@]} | tr ' ' '\n') #Now returns the expected subtraction of SAVED_RECORDs from NEW_RECs
fi
--- End Message ---
--- Begin Message ---Subject: grep -vf <(<nothing>) filters all rows Date: Thu, 2 Jan 2020 01:04:21 -0800 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 > I have to pre-check for an empty set before passing it to grep: > ... > Workaround: You're right that the empty pattern matches every line, since every line has an empty string in it somewhere. This is considered to be a feature of grep, not a bug. As you have a workaround I'm closing the bug report.
--- End Message ---
[Prev in Thread] | Current Thread | [Next in Thread] |