NetBSD Problem Report #49134
From www@NetBSD.org Wed Aug 20 23:20:59 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 7B26AAE528
for <gnats-bugs@gnats.NetBSD.org>; Wed, 20 Aug 2014 23:20:59 +0000 (UTC)
Message-Id: <20140820232057.1CA7EAE5A6@mollari.NetBSD.org>
Date: Wed, 20 Aug 2014 23:20:57 +0000 (UTC)
From: n54@gmx.com
Reply-To: n54@gmx.com
To: gnats-bugs@NetBSD.org
Subject: cksum, add new option -q -- quiet mode
X-Send-Pr-Version: www-1.0
>Number: 49134
>Category: bin
>Synopsis: cksum, add new option -q -- quiet mode
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Aug 20 23:25:00 +0000 2014
>Closed-Date: Tue Oct 14 06:45:20 +0000 2014
>Last-Modified: Tue Oct 14 06:45:20 +0000 2014
>Originator: Kamil Rytarowski
>Release: 6.99.47
>Organization:
>Environment:
NetBSD compaq 6.99.47 NetBSD 6.99.47 (NO_DRM) #0: Sat Jul 26 11:24:44 CEST 2014 root@chieftec:/usr/src/sys/arch/amd64/compile/NO_DRM amd64
>Description:
Family of cksum programs doesn't ship with a quiet mode, contrary to the one from FreeBSD (-q) and OpenBSD (-q).
Quiet mode is useful when someone needs plain checksum and cannot use (or simply doesn't want to use) pipes.
Discussion thread:
http://mail-index.netbsd.org/netbsd-users/2014/08/05/msg015067.html
>How-To-Repeat:
N/A
>Fix:
Index: cksum.1
===================================================================
RCS file: /cvsroot/src/usr.bin/cksum/cksum.1,v
retrieving revision 1.45
diff -u -r1.45 cksum.1
--- cksum.1 28 Mar 2013 22:54:25 -0000 1.45
+++ cksum.1 20 Aug 2014 22:57:25 -0000
@@ -47,32 +47,32 @@
.Sh SYNOPSIS
.Nm cksum
.Op Fl n
-.Op Fl a Ar algorithm Oo Fl ptx Oc Oo Fl s Ar string Oc
+.Op Fl a Ar algorithm Oo Fl pqtx Oc Oo Fl s Ar string Oc
.Op Fl o Ar 1 Ns | Ns Ar 2
.Op Ar Li \&| Fl c Oo Fl w Oc Oo Ar sumfile Oc
.Nm sum
.Op Fl n
-.Op Fl a Ar algorithm Oo Fl ptx Oc Oo Fl s Ar string Oc
+.Op Fl a Ar algorithm Oo Fl pqtx Oc Oo Fl s Ar string Oc
.Op Fl o Ar 1 Ns | Ns Ar 2
.Op Ar Li \&| Fl c Oo Fl w Oc Oo Ar sumfile Oc
.Nm md2
-.Op Fl nptx
+.Op Fl npqtx
.Op Fl s Ar string
.Op Ar Li \&| Fl c Oo Fl w Oc Oo Ar sumfile Oc
.Nm md4
-.Op Fl nptx
+.Op Fl npqtx
.Op Fl s Ar string
.Op Ar Li \&| Fl c Oo Fl w Oc Oo Ar sumfile Oc
.Nm md5
-.Op Fl nptx
+.Op Fl npqtx
.Op Fl s Ar string
.Op Ar Li \&| Fl c Oo Fl w Oc Oo Ar sumfile Oc
.Nm rmd160
-.Op Fl nptx
+.Op Fl npqtx
.Op Fl s Ar string
.Op Ar Li \&| Fl c Oo Fl w Oc Oo Ar sumfile Oc
.Nm sha1
-.Op Fl nptx
+.Op Fl npqtx
.Op Fl s Ar string
.Op Ar Li \&| Fl c Oo Fl w Oc Oo Ar sumfile Oc
.Sh DESCRIPTION
@@ -191,6 +191,10 @@
.It Fl p
Echo input from standard input to standard output, and append the
selected message digest.
+.It Fl q
+Quiet mode \(em only the checksum is printed out. Overrides the
+.Fl n
+option.
.It Fl s Ar string
Print the hash of the given string
.Ar string .
@@ -323,6 +327,10 @@
.Pq Fl c
first appeared in
.Nx 4.0 .
+Quiet mode
+.Pq Fl q
+was added in
+.Nx 7.0 .
.\" .Pp
.\" The
.\" .Nm sum
Index: cksum.c
===================================================================
RCS file: /cvsroot/src/usr.bin/cksum/cksum.c,v
retrieving revision 1.46
diff -u -r1.46 cksum.c
--- cksum.c 18 Oct 2013 20:47:06 -0000 1.46
+++ cksum.c 20 Aug 2014 22:57:25 -0000
@@ -104,6 +104,9 @@
#include "extern.h"
+#define PRINT_NORMAL 0x01
+#define PRINT_QUIET 0x02
+
typedef char *(*_filefunc)(const char *, char *);
const struct hash {
@@ -157,14 +160,15 @@
int (*cfncn) (int, u_int32_t *, off_t *);
void (*pfncn) (char *, u_int32_t, off_t);
const struct hash *hash;
- int normal, i, check_warn, do_check;
+ int i, check_warn, do_check;
+ int print_flags;
cfncn = NULL;
pfncn = NULL;
pflag = nohashstdin = 0;
- normal = 0;
check_warn = 0;
do_check = 0;
+ print_flags = 0;
setlocale(LC_ALL, "");
@@ -186,7 +190,7 @@
}
}
- while ((ch = getopt(argc, argv, "a:cno:ps:twx")) != -1)
+ while ((ch = getopt(argc, argv, "a:cno:pqs:twx")) != -1)
switch(ch) {
case 'a':
if (hash) {
@@ -221,7 +225,7 @@
do_check = 1;
break;
case 'n':
- normal = 1;
+ print_flags |= PRINT_NORMAL;
break;
case 'o':
if (hash) {
@@ -245,6 +249,9 @@
requirehash("-p");
pflag = 1;
break;
+ case 'q':
+ print_flags |= PRINT_QUIET;
+ break;
case 's':
if (hash == NULL)
requirehash("-s");
@@ -310,7 +317,7 @@
* Assume 'normal' output if there's a '('
*/
p_filename += 1;
- normal = 0;
+ print_flags &= ~(PRINT_NORMAL);
p_cksum = strrchr(p_filename, ')');
if (p_cksum == NULL) {
@@ -364,7 +371,7 @@
/*
* 'normal' output, no (ck)sum
*/
- normal = 1;
+ print_flags |= PRINT_NORMAL;
nspaces = 1;
p_cksum = buf;
@@ -468,7 +475,7 @@
if (*argv) {
fn = *argv++;
if (hash != NULL) {
- if (hash_digest_file(fn, hash, normal)) {
+ if (hash_digest_file(fn, hash, print_flags)) {
warn("%s", fn);
rval = 1;
}
@@ -497,7 +504,7 @@
}
static int
-hash_digest_file(char *fn, const struct hash *hash, int normal)
+hash_digest_file(char *fn, const struct hash *hash, int flags)
{
char *cp;
@@ -505,7 +512,9 @@
if (cp == NULL)
return 1;
- if (normal)
+ if (flags & PRINT_QUIET)
+ printf("%s\n", cp);
+ else if (flags & PRINT_NORMAL)
printf("%s %s\n", cp, fn);
else
printf("%s (%s) = %s\n", hash->hashname, fn, cp);
>Release-Note:
>Audit-Trail:
From: "Kamil Rytarowski" <n54@gmx.com>
To: gnats-bugs@gnats.netbsd.org
Cc:
Subject: Re: bin/49134
Date: Sat, 30 Aug 2014 22:47:19 +0200
Ping :-) Any sponsor to review and push?
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/49134 CVS commit: src/usr.bin/cksum
Date: Sun, 31 Aug 2014 03:05:33 -0400
Module Name: src
Committed By: christos
Date: Sun Aug 31 07:05:33 UTC 2014
Modified Files:
src/usr.bin/cksum: cksum.1 cksum.c
Log Message:
PR/49134: Kamil Rytarowski: Add -q flag.
To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/cksum/cksum.1
cvs rdiff -u -r1.46 -r1.47 src/usr.bin/cksum/cksum.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
n54@gmx.com
Cc:
Subject: Re: bin/49134
Date: Sun, 31 Aug 2014 03:05:46 -0400
On Aug 30, 8:50pm, n54@gmx.com ("Kamil Rytarowski") wrote:
-- Subject: Re: bin/49134
| The following reply was made to PR bin/49134; it has been noted by GNATS.
|
| From: "Kamil Rytarowski" <n54@gmx.com>
| To: gnats-bugs@gnats.netbsd.org
| Cc:
| Subject: Re: bin/49134
| Date: Sat, 30 Aug 2014 22:47:19 +0200
|
| Ping :-) Any sponsor to review and push?
committed.
christos
From: "Kamil Rytarowski" <n54@gmx.com>
To: christos@netbsd.org, gnats-bugs@gnats.netbsd.org
Cc:
Subject: Re: bin/49134
Date: Sun, 31 Aug 2014 12:10:22 +0200
Thank you very much!
=C2=A0
Please merge the changes with netbsd-7 and then close this issue.
From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/49134 CVS commit: [netbsd-7] src/usr.bin/cksum
Date: Sun, 31 Aug 2014 17:23:00 +0000
Module Name: src
Committed By: riz
Date: Sun Aug 31 17:23:00 UTC 2014
Modified Files:
src/usr.bin/cksum [netbsd-7]: cksum.1 cksum.c
Log Message:
Pull up following revision(s) (requested by christos in ticket #73):
usr.bin/cksum/cksum.1: revision 1.46
usr.bin/cksum/cksum.1: revision 1.47
usr.bin/cksum/cksum.c: revision 1.47
PR/49134: Kamil Rytarowski: Add -q flag.
New sentence, new line.
To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.45.6.1 src/usr.bin/cksum/cksum.1
cvs rdiff -u -r1.46 -r1.46.4.1 src/usr.bin/cksum/cksum.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Tue, 14 Oct 2014 06:45:20 +0000
State-Changed-Why:
fixed, thanks
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.