From owner-freebsd-standards Sun Feb 17 19:15:42 2002 Delivered-To: freebsd-standards@freebsd.org Received: from descent.robbins.dropbear.id.au (252.b.007.mel.iprimus.net.au [210.50.81.252]) by hub.freebsd.org (Postfix) with ESMTP id 6E87337B402 for ; Sun, 17 Feb 2002 19:15:30 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g1I3EF533231 for freebsd-standards@FreeBSD.ORG; Mon, 18 Feb 2002 14:14:15 +1100 (EST) (envelope-from tim) Date: Mon, 18 Feb 2002 14:14:15 +1100 From: Tim Robbins To: freebsd-standards@FreeBSD.ORG Subject: unexpand -t option Message-ID: <20020218141415.A33138@descent.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG This patch adds the -t option to unexpand, makes it use getopt instead of rolling its own option parser, and just generally cleans it up and simplifies it. Now that it no longer buffers output itself, it should be trivial to convert to support multibyte encoding: make `ch' in tabify() a rune_t, use fgetrune() and fputrune() instead of getchar()/putchar(). Should I make this change? (The standard suggests it should handle multibyte encodings when LC_CTYPE specifies one) Comments? Index: unexpand/unexpand.c =================================================================== RCS file: /home/ncvs/src/usr.bin/unexpand/unexpand.c,v retrieving revision 1.7 diff -u -r1.7 unexpand.c --- unexpand/unexpand.c 2001/12/11 23:18:25 1.7 +++ unexpand/unexpand.c 2002/02/18 03:07:21 @@ -52,13 +52,16 @@ #include #include #include +#include +#include -char genbuf[BUFSIZ]; -char linebuf[BUFSIZ]; int all; +int nstops; +int tabstops[100]; +static void getstops __P((char *)); static void usage __P((void)); -void tabify __P((char)); +void tabify __P((void)); int main(argc, argv) @@ -66,28 +69,34 @@ char *argv[]; { register char *cp; + int ch; - argc--, argv++; - if (argc > 0 && argv[0][0] == '-') { - if (strcmp(argv[0], "-a") != 0) + nstops = 1; + tabstops[0] = 8; + while ((ch = getopt(argc, argv, "at:")) != -1) { + switch (ch) { + case 'a': + all = 1; + break; + case 't': + getstops(optarg); + all = 1; + break; + default: usage(); - all++; - argc--, argv++; + /*NOTREACHED*/ + } } + argc -= optind; + argv += optind; + do { if (argc > 0) { if (freopen(argv[0], "r", stdin) == NULL) - err(1, "%s", argv[0]); + err(EX_NOINPUT, "%s", argv[0]); argc--, argv++; } - while (fgets(genbuf, BUFSIZ, stdin) != NULL) { - for (cp = linebuf; *cp; cp++) - continue; - if (cp > linebuf) - cp[-1] = 0; - tabify(all); - printf("%s", linebuf); - } + tabify(); } while (argc > 0); exit(0); } @@ -95,52 +104,98 @@ static void usage() { - fprintf(stderr, "usage: unexpand [-a] file ...\n"); - exit(1); + fprintf(stderr, "usage: unexpand [-a] [-t tablist] [file ...]\n"); + exit(EX_USAGE); } void -tabify(c) - char c; +tabify() { - register char *cp, *dp; register int dcol; - int ocol; + int ch, n, ocol; ocol = 0; dcol = 0; - cp = genbuf, dp = linebuf; - for (;;) { - switch (*cp) { - + while ((ch = getchar()) != EOF) { +top: switch (ch) { + case EOF: + return; + case '\n': + putchar('\n'); + ocol = dcol = 0; + break; case ' ': dcol++; break; - case '\t': dcol += 8; dcol &= ~07; break; - + case '\b': + if (dcol > 0) + dcol--; + /*FALLTHROUGH*/ default: - while (((ocol + 8) &~ 07) <= dcol) { - if (ocol + 1 == dcol) - break; - *dp++ = '\t'; - ocol += 8; - ocol &= ~07; + if (nstops == 1) { + while (((ocol + tabstops[0]) / tabstops[0]) + <= (dcol / tabstops[0])) { + if (dcol - ocol < 2) + break; + putchar('\t'); + ocol = (1 + ocol / tabstops[0]) * + tabstops[0]; + } + } else { + for (n = 0; n < nstops; n++) + if (tabstops[n] > ocol) + break; + for (; n != nstops && tabstops[n] <= dcol; + n++) { + putchar('\t'); + if (n == 0) + ocol = tabstops[n]; + else + ocol = tabstops[n] + + (ocol - tabstops[n - 1]); + } } while (ocol < dcol) { - *dp++ = ' '; + putchar(' '); ocol++; } - if (*cp == 0 || c == 0) { - strcpy(dp, cp); - return; + putchar(ch); + if (!all) { + while ((ch = getchar()) != EOF && ch != '\n') + putchar(ch); + goto top; } - *dp++ = *cp; ocol++, dcol++; } + } +} + +static void +getstops(cp) + register char *cp; +{ + register int i; + + nstops = 0; + for (;;) { + i = 0; + while (*cp >= '0' && *cp <= '9') + i = i * 10 + *cp++ - '0'; + if (i <= 0) + errx(1, "bad tab stop spec"); + if (nstops > 0 && i <= tabstops[nstops-1]) + errx(1, "bad tab stop spec"); + if (nstops == sizeof(tabstops) / sizeof(*tabstops)) + errx(1, "too many tabstops"); + tabstops[nstops++] = i; + if (*cp == 0) + break; + if (*cp != ',' && *cp != ' ') + errx(1, "bad tab stop spec"); cp++; } } Ugh! The expand(1) and unexpand(1) manual pages are stuck together. Index: expand/expand.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/expand/expand.1,v retrieving revision 1.7 diff -u -r1.7 expand.1 --- expand/expand.1 2001/07/10 14:15:57 1.7 +++ expand/expand.1 2002/02/18 02:16:14 @@ -51,6 +51,12 @@ .Op Ar .Nm unexpand .Op Fl a +.Oo +.Fl t +.Sm off +.Ar tab1 , tab2 , ... , tabn +.Sm on +.Oc .Op Ar .Sh DESCRIPTION .Nm Expand @@ -91,3 +97,10 @@ .Nm command appeared in .Bx 3.0 . +.Pp +The +.Nm expand +and +.Nm unexpand +utilities are expected to conform to +.St -p1003.1-2001 . To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Sun Feb 17 20:33:54 2002 Delivered-To: freebsd-standards@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id AD44737B43F for ; Sun, 17 Feb 2002 20:33:36 -0800 (PST) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.11.4/8.11.6) id g1I4XTo73238; Sun, 17 Feb 2002 23:33:29 -0500 (EST) (envelope-from wollman) Date: Sun, 17 Feb 2002 23:33:29 -0500 (EST) From: Garrett Wollman Message-Id: <200202180433.g1I4XTo73238@khavrinen.lcs.mit.edu> To: Tim Robbins Cc: freebsd-standards@FreeBSD.ORG Subject: unexpand -t option In-Reply-To: <20020218141415.A33138@descent.robbins.dropbear.id.au> References: <20020218141415.A33138@descent.robbins.dropbear.id.au> Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG < said: > to support multibyte encoding: make `ch' in tabify() a rune_t, use > fgetrune() and fputrune() instead of getchar()/putchar(). Should I make > this change? No. There is a Standard way to do this, which we haven't managed to implement yet. I believe the CITRUS project was working on that, but I haven't heard anything from them in quite a few months now.... -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Feb 18 18:39:54 2002 Delivered-To: freebsd-standards@freebsd.org Received: from rwcrmhc54.attbi.com (rwcrmhc54.attbi.com [216.148.227.87]) by hub.freebsd.org (Postfix) with ESMTP id 1FDF937B47D for ; Mon, 18 Feb 2002 18:39:01 -0800 (PST) Received: from gateway.posi.net ([12.236.90.177]) by rwcrmhc54.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020219023900.RLTW1214.rwcrmhc54.attbi.com@gateway.posi.net>; Tue, 19 Feb 2002 02:39:00 +0000 Received: from localhost (kbyanc@localhost) by gateway.posi.net (8.11.6/8.11.6) with ESMTP id g1J2cwq67559; Mon, 18 Feb 2002 18:38:59 -0800 (PST) (envelope-from kbyanc@posi.net) X-Authentication-Warning: gateway.posi.net: kbyanc owned process doing -bs Date: Mon, 18 Feb 2002 18:38:58 -0800 (PST) From: Kelly Yancey To: Tim Robbins Cc: freebsd-standards@FreeBSD.ORG Subject: Re: unexpand -t option In-Reply-To: <20020218141415.A33138@descent.robbins.dropbear.id.au> Message-ID: <20020218183522.D67464-100000@gateway.posi.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, 18 Feb 2002, Tim Robbins wrote: > This patch adds the -t option to unexpand, makes it use getopt instead of > rolling its own option parser, and just generally cleans it up and simplifies > it. > > Now that it no longer buffers output itself, it should be trivial to convert > to support multibyte encoding: make `ch' in tabify() a rune_t, use > fgetrune() and fputrune() instead of getchar()/putchar(). Should I make > this change? (The standard suggests it should handle multibyte encodings > when LC_CTYPE specifies one) > > Comments? > I cannot comment on the patch, but please don't introduce BSD-specific rune references. David Cross and I are working on flushing out wide character support which I would prefer to use as it is part of the C standard and the Single Unix specification. Thanks, Kelly kbyanc@{posi.net,FreeBSD.org} To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Feb 18 18:41:29 2002 Delivered-To: freebsd-standards@freebsd.org Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by hub.freebsd.org (Postfix) with ESMTP id 3BB5F37B404 for ; Mon, 18 Feb 2002 18:41:26 -0800 (PST) Received: from gateway.posi.net ([12.236.90.177]) by rwcrmhc52.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020219024125.PQCM1147.rwcrmhc52.attbi.com@gateway.posi.net>; Tue, 19 Feb 2002 02:41:25 +0000 Received: from localhost (kbyanc@localhost) by gateway.posi.net (8.11.6/8.11.6) with ESMTP id g1J2fNx67566; Mon, 18 Feb 2002 18:41:24 -0800 (PST) (envelope-from kbyanc@posi.net) X-Authentication-Warning: gateway.posi.net: kbyanc owned process doing -bs Date: Mon, 18 Feb 2002 18:41:23 -0800 (PST) From: Kelly Yancey To: Garrett Wollman Cc: Tim Robbins , Subject: Re: unexpand -t option In-Reply-To: <200202180433.g1I4XTo73238@khavrinen.lcs.mit.edu> Message-ID: <20020218183923.L67464-100000@gateway.posi.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 17 Feb 2002, Garrett Wollman wrote: > < said: > > > to support multibyte encoding: make `ch' in tabify() a rune_t, use > > fgetrune() and fputrune() instead of getchar()/putchar(). Should I make > > this change? > > No. There is a Standard way to do this, which we haven't managed to > implement yet. I believe the CITRUS project was working on that, but > I haven't heard anything from them in quite a few months now.... > > -GAWollman > The CITRUS project's FreeBSD codebase seems to be suffering from bit-rot. However, David Cross and I are working on porting NetBSD's implementation (which, again, comes from CITRUS) to FreeBSD. Kelly kbyanc@{posi.net,FreeBSD.org} To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Feb 19 4: 5:19 2002 Delivered-To: freebsd-standards@freebsd.org Received: from a96180.upc-a.chello.nl (a96180.upc-a.chello.nl [62.163.96.180]) by hub.freebsd.org (Postfix) with ESMTP id 0580237B419 for ; Tue, 19 Feb 2002 04:05:17 -0800 (PST) Received: by a96180.upc-a.chello.nl (Postfix, from userid 1001) id 296F1216E; Tue, 19 Feb 2002 13:05:16 +0100 (CET) Date: Tue, 19 Feb 2002 13:05:15 +0100 From: Jeroen Ruigrok/asmodai To: freebsd-standards@FreeBSD.ORG Subject: TenDRA and standards Message-ID: <20020219120515.GU4470@daemon.ninth-circle.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.24i Organisation: Ninth Circle Enterprises Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Just to keep you guys informed. I am currently working on adding ansi99 support to TenDRA and hope, thanks to Patryk, to have rudimentary C++ support for TenDRA in a few months. Right now TenDRA is K&R and C90 compliant for all I know. I would appreciate any odd things you would find right now. I've put preliminary pages up on http://www.tendra.org/. All kinds of wishes, ideas, bug reports and the likes are appreciated. Thanks, -- Jeroen Ruigrok van der Werven / asmodai / Kita no Mono asmodai@[wxs.nl|xmach.org], finger asmodai@ninth-circle.org http://www.softweyr.com/asmodai/ | http://www.tendra.org/ You confuse me in a way that I've never known... To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Feb 19 11:48: 4 2002 Delivered-To: freebsd-standards@freebsd.org Received: from hda.hda.com (host65.hda.com [63.104.68.65]) by hub.freebsd.org (Postfix) with ESMTP id 3F46F37B416; Tue, 19 Feb 2002 11:48:00 -0800 (PST) Received: (from dufault@localhost) by hda.hda.com (8.11.6/8.11.6) id g1JJlvs00665; Tue, 19 Feb 2002 14:47:57 -0500 (EST) (envelope-from dufault) Date: Tue, 19 Feb 2002 14:47:56 -0500 From: Peter Dufault To: Mike Barcroft Cc: "Jacques A. Vidrine" , Chuck Rouillard , FreeBSD-Standards Subject: Re: pathchk - review Message-ID: <20020219144756.A636@hda.hda.com> References: <20020129210829.GC50337@madman.nectar.cc> <20020205232519.N7805-101000@opus.sandiegoca.ncr.com> <20020212170303.B55750@espresso.q9media.com> <20020217020217.GB46829@madman.nectar.cc> <20020217004339.J57687@espresso.q9media.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020217004339.J57687@espresso.q9media.com>; from mike@FreeBSD.ORG on Sun, Feb 17, 2002 at 12:43:39AM -0500 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > The type is a pointer to a read-only string. The type he was really > looking for was a read-only pointer to a read-only string: > > const char * const VARIABLE; > > But as I suggested, manifest constants are better. No, debuggers don't handle them well. "When possible, avoid the preprocessor" IMHO. The same applies to magic numbers versus enums. Peter -- Peter Dufault (dufault@hda.com) Realtime development, Machine control, HD Associates, Inc. Fail-Safe systems, Agency approval To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Feb 19 15:49:41 2002 Delivered-To: freebsd-standards@freebsd.org Received: from espresso.q9media.com (espresso.q9media.com [216.254.138.122]) by hub.freebsd.org (Postfix) with ESMTP id 8315237B402 for ; Tue, 19 Feb 2002 15:49:37 -0800 (PST) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g1JNjFl77596; Tue, 19 Feb 2002 18:45:15 -0500 (EST) (envelope-from mike) Date: Tue, 19 Feb 2002 18:45:15 -0500 From: Mike Barcroft To: Peter Dufault Cc: FreeBSD-Standards Subject: Re: pathchk - review Message-ID: <20020219184515.G5526@espresso.q9media.com> References: <20020129210829.GC50337@madman.nectar.cc> <20020205232519.N7805-101000@opus.sandiegoca.ncr.com> <20020212170303.B55750@espresso.q9media.com> <20020217020217.GB46829@madman.nectar.cc> <20020217004339.J57687@espresso.q9media.com> <20020219144756.A636@hda.hda.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="p4qYPpj5QlsIQJ0K" Content-Disposition: inline In-Reply-To: <20020219144756.A636@hda.hda.com>; from dufault@hda.hda.com on Tue, Feb 19, 2002 at 02:47:56PM -0500 Organization: The FreeBSD Project Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --p4qYPpj5QlsIQJ0K Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Peter Dufault writes: > > The type is a pointer to a read-only string. The type he was really > > looking for was a read-only pointer to a read-only string: > > > > const char * const VARIABLE; > > > > But as I suggested, manifest constants are better. > > No, debuggers don't handle them well. "When possible, avoid the > preprocessor" IMHO. The same applies to magic numbers versus enums. Obviously what you're saying doesn't apply to the code in question. We will never need to debug fprint(3) or err(3) calls. Also, as Bruce pointed out in a private e-mail, atleast two of the variables should be string literals, since they are only used once. I also disagree with what you're saying in the general case. Things that are read-only aren't usually the things one is interesting in, when debugging. I've attached a sample program which uses the two forms discussed above. Are you able to differentiate them when you debug this program? I'm certainly not able to. Converting magic numbers is also pretty easy when you have the source. Here's what Peter van der Linden had to say about enum in his book, Expect C Programming: "In a weakly typed language like C, they provide very little that can't be done with a #define, so they were omitted from most early implementations of K&R C. But they're in most other languages, so C finally got them too." I'm going to get this code cleaned up and committed, since I think Chuck is no longer interested in it. Best regards, Mike Barcroft --p4qYPpj5QlsIQJ0K Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sample.c" #include const char * const MYVAR = "test"; #define MYVAR2 "test2" static void myfunc(const char * const, const char * const); int main(void) { myfunc(MYVAR, MYVAR2); exit(0); } static void myfunc(const char * const arg, const char * const arg2) { abort(); } --p4qYPpj5QlsIQJ0K-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Feb 19 16:38:54 2002 Delivered-To: freebsd-standards@freebsd.org Received: from rwcrmhc53.attbi.com (rwcrmhc53.attbi.com [204.127.198.39]) by hub.freebsd.org (Postfix) with ESMTP id CFDFF37B404 for ; Tue, 19 Feb 2002 16:38:48 -0800 (PST) Received: from attbi.com ([12.237.33.57]) by rwcrmhc53.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020220003848.TKWS2951.rwcrmhc53.attbi.com@attbi.com> for ; Wed, 20 Feb 2002 00:38:48 +0000 Message-ID: <3C72F01F.510DCB4B@attbi.com> Date: Tue, 19 Feb 2002 18:38:55 -0600 From: Joe Halpin X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.2-2 i686) X-Accept-Language: en MIME-Version: 1.0 Cc: FreeBSD-Standards Subject: Re: pathchk - review References: <20020129210829.GC50337@madman.nectar.cc> <20020205232519.N7805-101000@opus.sandiegoca.ncr.com> <20020212170303.B55750@espresso.q9media.com> <20020217020217.GB46829@madman.nectar.cc> <20020217004339.J57687@espresso.q9media.com> <20020219144756.A636@hda.hda.com> <20020219184515.G5526@espresso.q9media.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Mike Barcroft wrote: > > Peter Dufault writes: > > > The type is a pointer to a read-only string. The type he was really > > > looking for was a read-only pointer to a read-only string: > > > > > > const char * const VARIABLE; > > > > > > But as I suggested, manifest constants are better. > > > > No, debuggers don't handle them well. "When possible, avoid the > > preprocessor" IMHO. The same applies to magic numbers versus enums. > > Obviously what you're saying doesn't apply to the code in question. > We will never need to debug fprint(3) or err(3) calls. Also, as Bruce > pointed out in a private e-mail, atleast two of the variables should > be string literals, since they are only used once. > > I also disagree with what you're saying in the general case. Things > that are read-only aren't usually the things one is interesting in, > when debugging. I've attached a sample program which uses the two > forms discussed above. Are you able to differentiate them when you > debug this program? I'm certainly not able to. I missed the beginning of this, so I might be saying something irrelevant, but it seems to me that one very good reason for using const char pointers rather than the preprocessor is that const char * respects scope, and won't blindly overwrite other things.For the same reason, I prefer inline functions to function-like macros, not to mention the fact that inline functions offer some type safety. I became a believer in this after a bad experience with curses macros. Joe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Wed Feb 20 18:20: 1 2002 Delivered-To: freebsd-standards@freebsd.org Received: from espresso.q9media.com (espresso.q9media.com [216.254.138.122]) by hub.freebsd.org (Postfix) with ESMTP id 0E27237B400 for ; Wed, 20 Feb 2002 18:19:54 -0800 (PST) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g1L2FPK56516; Wed, 20 Feb 2002 21:15:25 -0500 (EST) (envelope-from mike) Date: Wed, 20 Feb 2002 21:15:25 -0500 From: Mike Barcroft To: Tim Robbins Cc: freebsd-standards@FreeBSD.ORG Subject: Re: env(1) and P1003.2-1992 conformance Message-ID: <20020220211525.A47845@espresso.q9media.com> References: <20020213135934.A4228@descent.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020213135934.A4228@descent.robbins.dropbear.id.au>; from tim@robbins.dropbear.id.au on Wed, Feb 13, 2002 at 01:59:35PM +1100 Organization: The FreeBSD Project Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Tim Robbins writes: > Here is a patch that corrects the exit status of the env utility to make > it compatible with P1003.2-1992. OpenBSD and NetBSD exit with the right > status (see NetBSD env.c revision 1.2 from 1993), FreeBSD does not. > This really is a trivial change. Committed (with a few minor mdoc changes). Thanks! Best regards, Mike Barcroft To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Wed Feb 20 18:48:34 2002 Delivered-To: freebsd-standards@freebsd.org Received: from opus.sandiegoca.ncr.com (tan7.ncr.com [192.127.94.7]) by hub.freebsd.org (Postfix) with ESMTP id F0C4637B404; Wed, 20 Feb 2002 18:48:31 -0800 (PST) Received: from localhost (chuckr@localhost) by opus.sandiegoca.ncr.com (8.11.6/8.11.6) with ESMTP id g1L2rp238006; Wed, 20 Feb 2002 18:53:51 -0800 (PST) (envelope-from chuckr@opus.sandiegoca.ncr.com) Date: Wed, 20 Feb 2002 18:53:51 -0800 (PST) From: Chuck Rouillard X-X-Sender: To: Mike Barcroft Cc: FreeBSD-Standards , Chuck Rouillard Subject: Re: pathchk - review Message-ID: <20020220184153.G37993-100000@localhost> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Mike Barcroft wrote: [snip] > I'm going to get this code cleaned up and committed, since I think > Chuck is no longer interested in it. Thanks. .cr To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Feb 21 16:22:21 2002 Delivered-To: freebsd-standards@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id CD22D37B404 for ; Thu, 21 Feb 2002 16:22:12 -0800 (PST) Received: from redrural.tragsatec.es ([212.49.178.252]) by khavrinen.lcs.mit.edu (8.11.4/8.11.6) with ESMTP id g1M0MBd29892 for ; Thu, 21 Feb 2002 19:22:11 -0500 (EST) (envelope-from rs@rn.com) Received: from adsl-65-70-142-161.dsl.kscymo.swbell.net by redrural.tragsatec.es with SMTP (Microsoft Exchange Internet Mail Service Version 5.0.1460.8) id FM33G1XD; Fri, 22 Feb 2002 00:40:33 +0100 From: To: freebsd-standards@bostonradio.org Subject: Waste Cost Review Date: Thu, 21 Feb 2002 17:48:05 Message-Id: <505.295716.821829@rn.com> Reply-To: rs@rn.com Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Quit throwing profits in your trash dumpster ! ! Savings average 39% Return on investment averages 2 months. Saving could begin tomorrow. One time fee of $45.00 Program objectives: 1. Work with your current waste vendor 2. Reduce heavy truck traffic on your property 3. Reduce unsightly dumpster overflow Program includes: 1. Review current practice 2. Survey equipment 3. Site specific program recommendations Any company that spends more that $75.00 per month for waste disposal (dumpster) may benefit. Car washes - Dry Cleaners - Retail Hardware Stores - Motels - Healthcare Clinics - Restaurants - Service Stations - Manufacturing - Distribution Centers - Grocery Stores Example of savings program: Ace Hardware Store: Prior cost $333.52 New cost $182.00 (same amount of service) Savings $151.52 45% Grocery Store in small market: Prior cost $680.00 New cost $235.00 (increase in service) Savings $445.00 65% Larger and more complex programs available Call Now To See How Waste Cost Reduction Programs (913) 725-9281 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Feb 21 20:35:17 2002 Delivered-To: freebsd-standards@freebsd.org Received: from descent.robbins.dropbear.id.au (156.a.005.mel.iprimus.net.au [210.50.40.156]) by hub.freebsd.org (Postfix) with ESMTP id 31D0B37B420; Thu, 21 Feb 2002 20:34:43 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g1M4XsV38018; Fri, 22 Feb 2002 15:33:54 +1100 (EST) (envelope-from tim) Date: Fri, 22 Feb 2002 15:33:54 +1100 (EST) Message-Id: <200202220433.g1M4XsV38018@descent.robbins.dropbear.id.au> To: FreeBSD-gnats-submit@freebsd.org Subject: link and unlink are not SUSv2-compliant as the manpage states From: Tim Robbins Reply-To: Tim Robbins Cc: freebsd-standards@freebsd.org X-send-pr-version: 3.113 X-GNATS-Notify: Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Submitter-Id: current-users >Originator: Tim Robbins >Organization: >Confidential: no >Synopsis: link and unlink are not SUSv2-compliant as the manpage states >Severity: non-critical >Priority: low >Category: bin >Class: sw-bug >Release: FreeBSD 4.5-STABLE i386 >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #4: Fri Feb 15 13:31:25 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: The manual pages for link and unlink, which are 'part of' ln and rm, and share the same manual pages, claim that these utilities are SUSV2 compliant. This is not the case. From The Single UNIX Specification, Version 2, XBD, Utility Argument Syntax: Guideline 10: "The argument -- should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the "-" character. The -- argument should not be used as an option or as an operand. Applications calling any utility with a first operand starting with - should usually specify --, as indicated by Guideline 10, to mark the end of the options ..." "... the Guidelines are rules for the standard utilities that claim conformance to them." link and unlink, therefore, should accept the "--" delimiter. Another problem is that when link's 2nd operand is a directory, it creates a link in that directory to the file named by the 1st operand, which is not correct. SUSV2 specifies that "link a b" is performs the equivalent of the function call link(a, b). unlink has the same problem: SUSV2 specifies it must call unlink() (which means it shouldn't treat whiteouts specially or try to reset immutable/append flags). >How-To-Repeat: N/A >Fix: Correct the manual pages by deleting the claims of SUSV2 conformance, or apply these patches that implement the correct behaviour. Index: ln/ln.c =================================================================== RCS file: /home/ncvs/src/bin/ln/ln.c,v retrieving revision 1.23 diff -u -r1.23 ln.c --- ln/ln.c 2002/02/02 06:44:35 1.23 +++ ln/ln.c 2002/02/22 04:00:47 @@ -85,11 +85,14 @@ else ++p; if (strcmp(p, "link") == 0) { - if (argc == 3) { - linkf = link; - exit(linkit(argv[1], argv[2], 0)); - } else + argv++, argc--; + if (argc > 0 && strncmp(*argv, "--", 2) == 0) + argv++, argc--; + if (argc != 2) usage(); + if (link(argv[0], argv[1]) != 0) + err(1, "%s to %s", argv[0], argv[1]); + exit(0); } while ((ch = getopt(argc, argv, "fhinsv")) != -1) Index: rm/rm.c =================================================================== RCS file: /home/ncvs/src/bin/rm/rm.c,v retrieving revision 1.36 diff -u -r1.36 rm.c --- rm/rm.c 2002/02/14 01:59:47 1.36 +++ rm/rm.c 2002/02/22 04:07:03 @@ -95,11 +95,14 @@ else ++p; if (strcmp(p, "unlink") == 0) { - if (argc == 2) { - rm_file(&argv[1]); - exit(eval); - } else + argv++, argc--; + if (argc > 0 && strncmp(*argv, "--", 2) == 0) + argv++, argc--; + if (argc != 1) usage(); + if (unlink(*argv) != 0) + err(1, "%s", *argv); + exit(0); } Pflag = rflag = 0; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Feb 22 4:40:16 2002 Delivered-To: freebsd-standards@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 1AB7737B402; Fri, 22 Feb 2002 04:40:13 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id XAA07619; Fri, 22 Feb 2002 23:40:08 +1100 Date: Fri, 22 Feb 2002 23:40:19 +1100 (EST) From: Bruce Evans X-X-Sender: To: Tim Robbins Cc: , Subject: Re: bin/35201: link and unlink are not SUSv2-compliant as the manpage states In-Reply-To: <200202220433.g1M4XsV38018@descent.robbins.dropbear.id.au> Message-ID: <20020222233126.Y25184-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 22 Feb 2002, Tim Robbins wrote: > >Description: > The manual pages for link and unlink, which are 'part of' ln and rm, > and share the same manual pages, claim that these utilities are SUSV2 > compliant. This is not the case. > > >From The Single UNIX Specification, Version 2, XBD, Utility Argument Syntax: > Guideline 10: > "The argument -- should be accepted as a delimiter indicating the end of > options. Any following arguments should be treated as operands, even if they Can you quote POSIX.1-2001? It is more authoritative, and almost as easy to find. > ... > link and unlink, therefore, should accept the "--" delimiter. The fix for this part should use getopt(3) instead of yet more home made arg parsing. getopt(3) gives special semantics "--" automagically. I think they are the same as specified in the guidelines. Otherwise, many other utilities would have this bug. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Feb 22 6: 4:10 2002 Delivered-To: freebsd-standards@freebsd.org Received: from descent.robbins.dropbear.id.au (009.a.002.mel.iprimus.net.au [203.134.133.9]) by hub.freebsd.org (Postfix) with ESMTP id ECC4F37B402; Fri, 22 Feb 2002 06:04:01 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g1ME0pV43234; Sat, 23 Feb 2002 01:00:51 +1100 (EST) (envelope-from tim) Date: Sat, 23 Feb 2002 01:00:50 +1100 From: Tim Robbins To: Bruce Evans Cc: FreeBSD-gnats-submit@FreeBSD.ORG, freebsd-standards@FreeBSD.ORG Subject: Re: bin/35201: link and unlink are not SUSv2-compliant as the manpage states Message-ID: <20020223010050.A43113@descent.robbins.dropbear.id.au> References: <200202220433.g1M4XsV38018@descent.robbins.dropbear.id.au> <20020222233126.Y25184-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020222233126.Y25184-100000@gamplex.bde.org>; from bde@zeta.org.au on Fri, Feb 22, 2002 at 11:40:19PM +1100 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Feb 22, 2002 at 11:40:19PM +1100, Bruce Evans wrote: > On Fri, 22 Feb 2002, Tim Robbins wrote: > > > >Description: > > The manual pages for link and unlink, which are 'part of' ln and rm, > > and share the same manual pages, claim that these utilities are SUSV2 > > compliant. This is not the case. > > > > >From The Single UNIX Specification, Version 2, XBD, Utility Argument Syntax: > > Guideline 10: > > "The argument -- should be accepted as a delimiter indicating the end of > > options. Any following arguments should be treated as operands, even if they > > Can you quote POSIX.1-2001? It is more authoritative, and almost as > easy to find. IEEE Std 1003.1-2001, Base Definitions, Utility Conventions, Utility Argument Syntax: Guideline 10: "The argument -- should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character. The -- argument should not be used as an option or as an operand." "The utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 that claim conformance to these guidelines shall conform completely to these guidelines as if these guidelines contained the term "shall" instead of "should"..." P1003.2-1992 is almost word-for-word the same. > > > ... > > link and unlink, therefore, should accept the "--" delimiter. > > The fix for this part should use getopt(3) instead of yet more home > made arg parsing. getopt(3) gives special semantics "--" automagically. > I think they are the same as specified in the guidelines. Otherwise, > many other utilities would have this bug. Yes, getopt(3)'s handling of -- is the same as that specified by the guidelines. I've adjusted the patches to rm and ln to use getopt instead of doing it themselves. I was hesitant in doing that at first because it breaks "unlink -foo", but P1003.2-1992 says: "Applications calling any utility with a first operand starting with "-" should usually specify "--", as indicated by Guideline 10, to mark the end of the options. This is true even if the Synopsis in this standard does not specify any options; implementations may provide options as extensions to this standard." ... and I'm not sure anyone really uses link/unlink, anyway. Index: rm/rm.c =================================================================== RCS file: /home/ncvs/src/bin/rm/rm.c,v retrieving revision 1.36 diff -u -r1.36 rm.c --- rm/rm.c 2002/02/14 01:59:47 1.36 +++ rm/rm.c 2002/02/22 13:46:57 @@ -95,11 +95,15 @@ else ++p; if (strcmp(p, "unlink") == 0) { - if (argc == 2) { - rm_file(&argv[1]); - exit(eval); - } else + if (getopt(argc, argv, "") != -1) usage(); + argc -= optind; + argv += optind; + if (argc != 1) + usage(); + if (unlink(*argv) != 0) + err(1, "%s", *argv); + exit(0); } Pflag = rflag = 0; Index: ln/ln.c =================================================================== RCS file: /home/ncvs/src/bin/ln/ln.c,v retrieving revision 1.23 diff -u -r1.23 ln.c --- ln/ln.c 2002/02/02 06:44:35 1.23 +++ ln/ln.c 2002/02/22 13:46:41 @@ -85,11 +85,15 @@ else ++p; if (strcmp(p, "link") == 0) { - if (argc == 3) { - linkf = link; - exit(linkit(argv[1], argv[2], 0)); - } else + if (getopt(argc, argv, "") != -1) usage(); + argc -= optind; + argv += optind; + if (argc != 2) + usage(); + if (link(argv[0], argv[1]) != 0) + err(1, "%s to %s", argv[0], argv[1]); + exit(0); } while ((ch = getopt(argc, argv, "fhinsv")) != -1) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Feb 22 6:21:52 2002 Delivered-To: freebsd-standards@freebsd.org Received: from straylight.ringlet.net (discworld.nanolink.com [217.75.135.248]) by hub.freebsd.org (Postfix) with SMTP id 6DEEA37B400 for ; Fri, 22 Feb 2002 06:21:47 -0800 (PST) Received: (qmail 68054 invoked by uid 1000); 22 Feb 2002 14:22:14 -0000 Date: Fri, 22 Feb 2002 16:22:14 +0200 From: Peter Pentchev To: Sheldon Hearn Cc: Tim Robbins , bug-followup@FreeBSD.org, freebsd-standards@FreeBSD.org Subject: Re: bin/35201: link and unlink are not SUSv2-compliant as the manpage states Message-ID: <20020222162214.H66747@straylight.oblivion.bg> References: <54382.1014387532@axl.seasidesoftware.co.za> <54422.1014387612@axl.seasidesoftware.co.za> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <54422.1014387612@axl.seasidesoftware.co.za>; from sheldonh@starjuice.net on Fri, Feb 22, 2002 at 04:20:12PM +0200 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Feb 22, 2002 at 04:20:12PM +0200, Sheldon Hearn wrote: > > > On Fri, 22 Feb 2002 16:18:52 +0200, Sheldon Hearn wrote: > > > The whole point of these alternatives to ln/rm is that they have a > > simple, optionless interface. :-( > > Bleh, what an entirely useless response. :-) > > I should have gone on to say... > > However, standards conformance is probably important, even here. If > scripts expect 'link -- foo bar' to work, and yet it breaks in FreeBSD, > that'll be bad. I agree with that; and IMHO, since these utilities are really *not* expected to do any options parsing, we should just accept Tim's original patches, even as they avoid getopt(3). G'luck, Peter -- Peter Pentchev roam@ringlet.net roam@FreeBSD.org PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 I've heard that this sentence is a rumor. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Sat Feb 23 9:26: 8 2002 Delivered-To: freebsd-standards@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 99FF237B405 for ; Sat, 23 Feb 2002 09:26:04 -0800 (PST) Received: from hth.bhel.co.in (IDENT:root@[202.41.63.7]) by khavrinen.lcs.mit.edu (8.11.4/8.11.6) with ESMTP id g1NHPxd55849 for ; Sat, 23 Feb 2002 12:26:00 -0500 (EST) (envelope-from rs@rn.com) Received: from rn.com (IDENT:root@localhost [127.0.0.1]) by hth.bhel.co.in (8.11.2/8.11.2) with SMTP id g1NHPmI24638 for ; Sat, 23 Feb 2002 22:55:58 +0530 From: To: freebsd-standards@bostonradio.org Subject: Waste Review Date: Sat, 23 Feb 2002 11:14:45 Message-Id: <173.465551.45910@rn.com> Reply-To: rs@rn.com Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Quit throwing profits in your trash dumpster ! ! Savings average 39% Return on investment averages 2 months. Saving could begin tomorrow. One time fee of $45.00 Program objectives: 1. Work with your current waste vendor 2. Reduce heavy truck traffic on your property 3. Reduce unsightly dumpster overflow Program includes: 1. Review current practice 2. Survey equipment 3. Site specific program recommendations Any company that spends $75.00 per month or more for waste disposal (dumpster) may benefit. Car washes - Dry Cleaners - Retail Hardware Stores - Motels - Healthcare Clinics - Restaurants - Service Stations - Manufacturing - Distribution Centers - Grocery Stores Example of savings program: Ace Hardware Store: Prior cost $333.52 New cost $182.00 (same amount of service) Savings $151.52 45% Grocery Store in small market: Prior cost $680.00 New cost $235.00 (increase in service) Savings $445.00 65% Larger and more complex programs available Call Now To See How Waste Cost Reduction Programs (913) 725-9281 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Sat Feb 23 21:28:47 2002 Delivered-To: freebsd-standards@freebsd.org Received: from descent.robbins.dropbear.id.au (133.c.008.mel.iprimus.net.au [210.50.88.133]) by hub.freebsd.org (Postfix) with ESMTP id 5E93737B416 for ; Sat, 23 Feb 2002 21:28:13 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g1O5ROf60233 for freebsd-standards@FreeBSD.ORG; Sun, 24 Feb 2002 16:27:24 +1100 (EST) (envelope-from tim) Date: Sun, 24 Feb 2002 16:27:24 +1100 From: Tim Robbins To: freebsd-standards@FreeBSD.ORG Subject: sh -h (-o trackall) option patch Message-ID: <20020224162724.A60220@descent.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Here's a patch to add the -h (-o trackall) option to sh. The P1003.1-2001 specification about this option is flawed, but I'm confident this is what was intended. (The flaw is that the -h option is listed in the SYNOPSIS section but not in the OPTIONS section. It should be listed along with the other options to the "set" builtin.) The name accepted by the -o option, trackall, is not specified by the standard, but is the traditional Korn Shell name for it. Index: options.h =================================================================== RCS file: /home/ncvs/src/bin/sh/options.h,v retrieving revision 1.11 diff -u -r1.11 options.h --- options.h 2002/02/02 06:50:47 1.11 +++ options.h 2002/02/24 05:23:22 @@ -65,8 +65,9 @@ #define uflag optlist[14].val #define privileged optlist[15].val #define Tflag optlist[16].val +#define hflag optlist[17].val -#define NOPTS 17 +#define NOPTS 18 struct optent { const char *name; @@ -93,6 +94,7 @@ { "nounset", 'u', 0 }, { "privileged", 'p', 0 }, { "trapsasync", 'T', 0 }, + { "trackall", 'h', 0 }, }; #else extern struct optent optlist[NOPTS]; Index: parser.c =================================================================== RCS file: /home/ncvs/src/bin/sh/parser.c,v retrieving revision 1.38 diff -u -r1.38 parser.c --- parser.c 2002/02/02 06:50:47 1.38 +++ parser.c 2002/02/24 05:23:25 @@ -60,6 +60,7 @@ #include "alias.h" #include "show.h" #include "eval.h" +#include "exec.h" #ifndef NO_HISTORY #include "myhistedit.h" #endif @@ -97,6 +98,7 @@ struct heredoc *heredoc; int quoteflag; /* set if (part of) last token was quoted */ int startlinno; /* line # where last token started */ +int funclevel; /* nesting level of functions */ /* XXX When 'noaliases' is set to one, no alias expansion takes place. */ static int noaliases = 0; @@ -530,6 +532,7 @@ STATIC union node * simplecmd(union node **rpp, union node *redir) { + struct cmdentry entry; union node *args, **app; union node **orig_rpp = rpp; union node *n = NULL, *n2; @@ -561,6 +564,9 @@ n->type = NARG; n->narg.text = wordtext; n->narg.backquote = backquotelist; + if (app == &args && funclevel > 0 && hflag) + /* Add hash entry for this command (-h option) */ + find_command(wordtext, &entry, 0, pathval()); *app = n; app = &n->narg.next; } else if (lasttoken == TREDIR) { @@ -577,7 +583,9 @@ synerror("Bad function name"); #endif n->type = NDEFUN; + funclevel++; n->narg.next = command(); + funclevel--; goto checkneg; } else { tokpushback++; Index: sh.1 =================================================================== RCS file: /home/ncvs/src/bin/sh/sh.1,v retrieving revision 1.58 diff -u -r1.58 sh.1 --- sh.1 2001/11/20 18:41:01 1.58 +++ sh.1 2002/02/24 05:23:31 @@ -43,7 +43,7 @@ .Nd command interpreter (shell) .Sh SYNOPSIS .Nm -.Op Fl /+abCEefIimnpsTuVvx +.Op Fl /+abCEefIhimnpsTuVvx .Op Fl /+o Ar longname .Op Fl c Ar string .Op Ar arg ...\& @@ -218,6 +218,9 @@ Ignore .Dv EOF Ns ' Ns s from input when in interactive mode. +.It Fl h Li trackall +Create tracked aliases for commands invoked by functions as they are defined. +By default, tracked aliases are created when the functions are executed. .It Fl i Li interactive Force the shell to behave interactively. .It Fl m Li monitor To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message