Date: Mon, 31 Dec 2001 00:10:02 -0800 (PST) From: Mike Heffner <mheffner@novacoxmail.com> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/32935: /bin/sh builtin echo command Message-ID: <200112310810.fBV8A2w35884@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/32935; it has been noted by GNATS.
From: Mike Heffner <mheffner@novacoxmail.com>
To: Sheldon Hearn <sheldonh@starjuice.net>,
freebsd-gnats-submit@freebsd.org
Cc: audit@FreeBSD.ORG
Subject: Re: bin/32935: /bin/sh builtin echo command
Date: Mon, 31 Dec 2001 03:05:51 -0500 (EST)
On 30-Dec-2001 Sheldon Hearn wrote:
|
| Hi folks,
|
| Could someone check out PR bin/32935, which contains a patch to fix
| ash's builtin echo command so that it accepts the -e and -n options
| combined?
|
Looks ok, except that I think in the '#define eflag 1' case it should
still accept '-ne' as valid and just ignore the 'e'. How about this:
Index: echo.c
===================================================================
RCS file: /home/ncvs/src/bin/sh/bltin/echo.c,v
retrieving revision 1.10
diff -u -r1.10 echo.c
--- echo.c 26 Jun 2000 22:43:30 -0000 1.10
+++ echo.c 31 Dec 2001 08:00:09 -0000
@@ -64,16 +64,28 @@
ap = argv;
if (argc)
ap++;
- if ((p = *ap) != NULL) {
- if (equal(p, "-n")) {
- nflag++;
- ap++;
- } else if (equal(p, "-e")) {
+ if ((p = *ap) != NULL && *p == '-') {
+ ap++;
+ p++;
+ do {
+ if (*p == 'n')
+ nflag++;
+ else if (*p == 'e')
#ifndef eflag
- eflag++;
+ eflag++;
+#else
+ ;
#endif
- ap++;
- }
+ else {
+ nflag = 0;
+#ifndef eflag
+ eflag = 0;
+#endif
+ ap--;
+ break;
+ }
+ } while (*++p != '\0');
+
}
while ((p = *ap++) != NULL) {
while ((c = *p++) != '\0') {
Mike
--
Mike Heffner <mheffner@[acm.]vt.edu>
Fredericksburg, VA <mikeh@FreeBSD.org>
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200112310810.fBV8A2w35884>
