[Bug 10411] New: grep -v -q not returning expected results when used with blkid

bugzilla at busybox.net bugzilla at busybox.net
Sun Oct 15 01:27:46 UTC 2017


https://bugs.busybox.net/show_bug.cgi?id=10411

            Bug ID: 10411
           Summary: grep -v -q not returning expected results when used
                    with blkid
           Product: Busybox
           Version: 1.27.x
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Other
          Assignee: unassigned at busybox.net
          Reporter: clayton at craftyguy.net
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

When trying to grep text from the output of blkid, I noticed that if I use -v
along with -q, that grep returns 0 regardless of whether or not there was a
match.


For reference, the output of blkid, and grepping blkid with -v:
# blkid
/dev/mmcblk1p3: UUID="5463935a-1361-4043-8a44-75498986c3e8" TYPE="swap"
/dev/mmcblk1p2: UUID="a15f4575-5886-4da6-9e13-caa7e6300f2c" TYPE="ext3"
/dev/mmcblk1p1: LABEL="Nokia N900" UUID="4BB1-EC06" TYPE="vfat"
/dev/mmcblk0p2: LABEL="pmOS_root" UUID="e54fb2af-97c3-4a47-af17-5ab6f0f4dba7"
TYPE="ext4"
/dev/mmcblk0p1: LABEL="pmOS_boot" UUID="5c24c382-1921-455f-b63b-dd053e55d0cb"
TYPE="ext2"
# blkid |grep -v pmOS_root
/dev/mmcblk1p3: UUID="5463935a-1361-4043-8a44-75498986c3e8" TYPE="swap"
/dev/mmcblk1p2: UUID="a15f4575-5886-4da6-9e13-caa7e6300f2c" TYPE="ext3"
/dev/mmcblk1p1: LABEL="Nokia N900" UUID="4BB1-EC06" TYPE="vfat"
/dev/mmcblk0p1: LABEL="pmOS_boot" UUID="5c24c382-1921-455f-b63b-dd053e55d0cb"
TYPE="ext2"


The output of these looks OK:
# blkid |grep -q  nope; echo $?
1

# blkid |grep -q -v nope; echo $?
0

This is NOT expected. The second command should have output 1:
# blkid |grep -q pmOS_root; echo $?
0

# blkid |grep -q -v pmOS_root; echo $?
0


The same test but replacing blkid with echo looks OK:

localhost:/home/user# echo pmOS_root |grep -q pmOS_root; echo $?
0

localhost:/home/user# echo pmOS_root |grep -q -v pmOS_root; echo $?
1

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list