uniq command line options parser seems to be broken

Originator:juan.ignacio.porta
Number:rdar://23989106 Date Originated:22-Dec-2015 04:01 PM
Status:Closed Resolved:Yes
Product:OS X Product Version:10.11.2 (15C50)
Classification: Reproducible:Always
 
Summary:
No matter which command line options you use to invoke the utility (I've tried -c, -d, and -u) it always works as if no command line parameters were used, i.e., it outputs the list of unique lines in the input.
Invoking the utility with an input file and no output file (it should output the results to standard output) blocks the utility, just like any utility blocks when taking its input from a pipe and nothing is coming through it.

Steps to Reproduce:
1. Run "cat /etc/hosts | uniq -c" (without the double quotes) in Terminal.app. Repeat replacing -c command line option in step 1 with -d or -u.
2. Run "uniq /etc/hosts" in Terminal.app (without the double quotes)

Expected Results:
1. A list of repeat counts and text lines from the input file, separated by space, a list of duplicated, and a list of unique lines in the input file, respectively.
2. A list of unique lines in the input file.

Actual Results:
1. The output is the same as running "cat /etc/hosts | uniq" (without the quotes).
2. The utility blocks as if it was expecting data from an input file.

Version:
Mac OS X El Capitan 10.11.2 (15C50)

Notes:
I think this is pretty serious since it breaks all scripts using uniq.

Configuration:
It happens all the time and does not require a special software or hardware configuration.

Attachments:

Comments

Thanks for your feedback. I know how uniq works but for this issue it didn't matter if the file was or was not sorted because the output didn't show the number of duplicate lines (which would be at least 1). Anyway, your comment made me dig a little further on the issue. Then I discovered the three computers with El Capitan I used to reproduce the bug had nixar (a shell extension) installed. And the computer with Yosemite I used to check it worked fine before 10.11 didn't have nixar, just an ugly coincidence and some laziness on my side. The problem is that nixar puts a copy of uniq in /usr/loca/bin/uniq and my PATH variable did the rest.

By juan.ignacio.porta at Jan. 11, 2016, 4:07 p.m. (reply...)

I can't replicate this. Keep in mind uniq only looks at adjacent lines, so you may need to pipe thru "sort" first to get the results you expect.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!