Date: Mon, 17 Dec 2001 18:27:02 +0300 From: "Vladimir B.Grebenschikov" <vova@sw.ru> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/32935: /bin/sh buildin echo command have invalid implimentation of command args parser Message-ID: <E16FzfS-0006UA-00@vbook.express.ru>
next in thread | raw e-mail | index | archive | help
>Number: 32935
>Category: bin
>Synopsis: /bin/sh buildin echo command have invalid implimentation of command args parser
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Dec 17 07:30:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Vladimir B. Grebenschikov
>Release: FreeBSD 5.0-CURRENT i386
>Organization:
SWsoft
>Environment:
System: FreeBSD vbook.express.ru 5.0-CURRENT FreeBSD 5.0-CURRENT #4: Mon Dec 17 12:45:42 MSK 2001 root@vbook.express.ru:/usr/local/src/sys/i386/compile/VBOOK i386
also same problem in 4.4-RELEASE
>Description:
According to manpage sh(1):
echo [-en] string
Print string to the standard output with a newline appended.
-n Suppress the output of the trailing newline.
-e Process C-style backslash escape sequences. echo under-
stands the following character escapes:
But in realality echo accepts either -n or -e flag but not both simultaneously.
>How-To-Repeat:
$ echo -en "\tGGG\nJJJ\nccc"
-en \tGGG\nJJJ\nccc
$
but:
$ echo -e "\tGGG\nJJJ\nccc"
GGG
JJJ
ccc
$
$ echo -n "test"
test$
>Fix:
diff -u src/bin/sh/bltin/echo.c:1.9.2.1
src/bin/sh/bltin/echo.c:1.9.2.1.10000.2
--- src/bin/sh/bltin/echo.c:1.9.2.1 Fri Jun 30 00:51:59 2000
+++ src/bin/sh/bltin/echo.c Mon Dec 17 18:15:23 2001
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)echo.c 8.2 (Berkeley) 5/4/95
- * $FreeBSD: src/bin/sh/bltin/echo.c,v 1.9.2.1 2000/06/29 20:51:59 mph Exp
$
+ * $FreeBSD: src/bin/sh/bltin/echo.c,v 1.9.2.1.10000.2 2001/12/17 15:15:23
kmv Exp $
*/
/*
@@ -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++;
+ }
+#ifndef eflag
+ else if (*p == 'e') {
+ eflag++;
+ }
+#endif
+ else {
+ nflag = 0;
#ifndef eflag
- eflag++;
+ eflag = 0;
#endif
- ap++;
- }
+ ap--;
+ break;
+ }
+ p++;
+ } while (*p);
}
while ((p = *ap++) != NULL) {
while ((c = *p++) != '\0') {
--
SWSoft, Moscow
Vladimir B. Grebenschikov vova@sw.ru
>Release-Note:
>Audit-Trail:
>Unformatted:
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?E16FzfS-0006UA-00>
