Discussion:
cksum new parameters -q and -r
Kamil Rytarowski
2014-08-05 08:27:18 UTC
Permalink
Hello,
 
I've been porting a piece of software for personal usage from Linux and FreeBSD to NetBSD.

I was looking for a GNU md5sum equivalent that works like `cksum -q` in FreeBSD [1] and OpenBSD [2]
"-q Only print the checksum (quiet mode) or if used in conjunction with the -c flag, only print the failed cases."

>From what I can see we miss it and we need to pipe a result of `md5` to a stream parser (sed, awk). This adds more burden in scripting languages that doesn't support piping.

FreeBSD and OpenBSD documentation expose that there is also one common command-line parameter -r:
"-r Reverse the format of the hash algorithm output, making it match the checksum output format.

Is it a good idea to add support for -q and -r in our tools and be compatible with FreeBSD and OpenBSD? There is also gmd5sum in pkgsrc, but it's some kind of overkill for this task.

Both parameters seem to be out of a POSIX/Unix standards scope.

I'm a volunteer to submit a patch.

With kind regards,

[1] http://www.unix.com/man-page/freebsd/1/md5/
 
[2] http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/cksum.1?query=cksum
Alistair Crooks
2014-08-05 20:46:32 UTC
Permalink
On Tue, Aug 05, 2014 at 10:27:18AM +0200, Kamil Rytarowski wrote:
> Hello,
> ?
> I've been porting a piece of software for personal usage from Linux
> and FreeBSD to NetBSD.
>
> I was looking for a GNU md5sum equivalent that works like `cksum -q`
> in FreeBSD [1] and OpenBSD [2] "-q Only print the checksum (quiet
> mode) or if used in conjunction with the -c flag, only print the
> failed cases."
>
> From what I can see we miss it and we need to pipe a result of `md5`
> to a stream parser (sed, awk). This adds more burden in scripting
> languages that doesn't support piping.

Just provide the file as stdin, e.g.

% md5 < Makefile
c484c4693b61f058087c0bb84091adfb
%

Regards,
Alistair
Kamil Rytarowski
2014-08-20 23:11:44 UTC
Permalink
"Alistair Crooks" <***@pkgsrc.org>, Tuesday, August 05, 2014 at 10:46 PM
> Just provide the file as stdin, e.g.
>
> % md5 < Makefile
> c484c4693b61f058087c0bb84091adfb
> %

Hello,

Thank you for your reply. Actually my idea was to omit pipes (as my tool doesn't support it in an unbitter way),

I've just pushed the things forward and did a research. NetBSD ships with '-n', an equivalent of '-r' from FreeBSD and OpenBSD. The quiet (-q) mode was added and the patch against current is attached to this mail.

I'll submit a public-report for this task along with the patch and link to this thread. I'm open for comments.

Thanks in advance,
Loading...