Subject: New cat(1) option (was: Re: Possible solution to toolchain/16963 - NBUILDJOBS/METALOG conflict)
To: Martin Husemann <>
From: Mason Loring Bliss <>
List: tech-userlevel
Date: 06/07/2002 15:46:06
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Jun 07, 2002 at 08:42:47AM +0200, Martin Husemann wrote:

> > Since this works, locking stdout would seem to be a useful option for
> > cat(1), perhaps.
> Sounds good, and cat even has free option letters left ;-)

It's the simplest solution of the lot, additionally.

> Any hint from relevant standards?

There's nothing that I can see. The only argument to cat noted in SuS2 is
"-u". I would suggest "-l" for "lock".

If no one objects to this, I'd like to apply the following patches to cat.
I'll give it until Monday for objections, unless discussions ensues in the

Along with this, I'd like to make basesrc/share/man/Makefile and
basesrc/share/zoneinfo/Makefile use this to lock METALOG, so that builds
with -j > 1 can complete. I'd also like to submit a pull-up request so that
netbsd-1-6 can build with -j > 1. However, this would require having cat as
a host tool, and I need to read more to see how to do that.  So, for
starters, I'd like to simply add this useful cat functionality to the base

Thanks in advance for constructive comments.

Index: cat.1
RCS file: /cvsroot/basesrc/bin/cat/cat.1,v
retrieving revision 1.25
diff -u -w -r1.25 cat.1
--- cat.1       2002/05/15 06:52:54     1.25
+++ cat.1       2002/06/07 19:39:38
@@ -79,6 +79,8 @@
 as well.
 .It Fl f
 Only attempt to display regular files.
+.It Fl l
+Set an exclusive advisory lock on the standard output file descriptor.
 .It Fl n
 Number the output lines, starting at 1.
 .It Fl s

Index: cat.c
RCS file: /cvsroot/basesrc/bin/cat/cat.c,v
retrieving revision 1.31
diff -u -w -r1.31 cat.c
--- cat.c	2002/05/09 02:19:42	1.31
+++ cat.c	2002/06/07 19:40:23
@@ -82,7 +82,7 @@
 	(void)setlocale(LC_ALL, "");
-	while ((ch =3D getopt(argc, argv, "befnstuv")) !=3D -1)
+	while ((ch =3D getopt(argc, argv, "beflnstuv")) !=3D -1)
 		switch (ch) {
 		case 'b':
 			bflag =3D nflag =3D 1;	/* -b implies -n */
@@ -93,6 +93,9 @@
 		case 'f':
 			fflag =3D 1;
+		case 'l':
+			break;
 		case 'n':
 			nflag =3D 1;
@@ -111,7 +114,7 @@
 		case '?':
-			    "usage: cat [-befnstuv] [-] [file ...]\n");
+			    "usage: cat [-beflnstuv] [-] [file ...]\n");
 			/* NOTREACHED */

Mason Loring Bliss   Ewige Blumenkraft!  awake ? sleep : random() & 2 ? dream : sleep;

Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.0.6 (NetBSD)
Comment: For info see