bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9987: [PATCH] groups,id: add -0, --null option


From: Bernhard Voelker
Subject: bug#9987: [PATCH] groups,id: add -0, --null option
Date: Tue, 17 Sep 2013 19:23:19 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5

On 09/17/2013 01:32 AM, Pádraig Brady wrote:
> Actually omitting the trailing \0 could be
> inconsistent and problematic?
> 
> 
> uniq and basename for example always output the trailing \0
> 
> $ basename -az 1/1 2/2 | od -Ax -tx1z -v
> 000000 31 00 32 00                                      >1.2.<
> 000004
> 
> $ printf "1\0002" | uniq -z | od -Ax -tx1z -v
> 000000 31 00 32 00                                      >1.2.<
> 000004
> 
> 
> Also handling only separated output in shell can be awkward:
> 
> # This is OK:
> $ groups | tr ' ' '\n' |  while read group; do echo $group; done | wc -l
> 4
> 
> # This drops the last item
> $ groups -z | tr '\0' '\n' | while read group; do echo $group; done | wc -l
> 3

Good point.
The changes in id.c and in groups.c are quite easy and make the changes
smaller there.  The bigger work is in the test.  To avoid double work,
I'll therefore prepare the other change first, i.e. removing the
"USERNAME : " prefix in the output of groups in the case
where only one argument was passed).

Thanks & have a nice day,
Berny





reply via email to

[Prev in Thread] Current Thread [Next in Thread]