From owner-freebsd-bugs Mon Dec 17 7:30:20 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 6F26437B41B for ; Mon, 17 Dec 2001 07:30:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id fBHFU1F21935; Mon, 17 Dec 2001 07:30:01 -0800 (PST) (envelope-from gnats) Received: from vbook.express.ru (asplinux.ru [195.133.213.194]) by hub.freebsd.org (Postfix) with ESMTP id 5C16837B416 for ; Mon, 17 Dec 2001 07:27:00 -0800 (PST) Received: from vova by vbook.express.ru with local (Exim 3.31 #2) id 16FzfS-0006UA-00 for FreeBSD-gnats-submit@freebsd.org; Mon, 17 Dec 2001 18:27:02 +0300 Message-Id: Date: Mon, 17 Dec 2001 18:27:02 +0300 From: "Vladimir B.Grebenschikov" Reply-To: "Vladimir B.Grebenschikov" To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/32935: /bin/sh buildin echo command have invalid implimentation of command args parser Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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