From owner-freebsd-current Tue Sep 15 15:37:30 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA26617 for freebsd-current-outgoing; Tue, 15 Sep 1998 15:37:30 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from smtp02.primenet.com (smtp02.primenet.com [206.165.6.132]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA26575 for ; Tue, 15 Sep 1998 15:37:17 -0700 (PDT) (envelope-from tlambert@usr06.primenet.com) Received: (from daemon@localhost) by smtp02.primenet.com (8.8.8/8.8.8) id PAA14989; Tue, 15 Sep 1998 15:36:57 -0700 (MST) Received: from usr06.primenet.com(206.165.6.206) via SMTP by smtp02.primenet.com, id smtpd014963; Tue Sep 15 15:36:55 1998 Received: (from tlambert@localhost) by usr06.primenet.com (8.8.5/8.8.5) id PAA09100; Tue, 15 Sep 1998 15:36:49 -0700 (MST) From: Terry Lambert Message-Id: <199809152236.PAA09100@usr06.primenet.com> Subject: Re: 'bug' in /bin/sh's builtin 'echo' To: crossd@cs.rpi.edu (David E. Cross) Date: Tue, 15 Sep 1998 22:36:49 +0000 (GMT) Cc: cracauer@cons.org, jmoss@ichips.intel.com, chet@po.cwru.edu, freebsd-current@FreeBSD.ORG In-Reply-To: from "David E. Cross" at Sep 15, 98 02:52:11 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > This one doesn't specify a -e option (in fact it specifies that echo > > should take no options at all), everything behaves as if -e was > > specified and all switches are echoed. I can hardly accept that as > > something to follow. > > With '\c', you don't need '-n' any more. \c is SysV, -n is Berkeley. For portable shell scripts (assuming shell functions are supported): TMP=`echo -n` if test "x$TMP" = "x" then DASHN="yes" else DASHN="no" fi NECHO() { if test "$DASHN" = "yes" then echo -n "$*" else echo "$*\c" fi } NECHO "This is my command line prompt: " read x ... Been there, done that a *long* time ago... > This is already the way our own /bin/echo works, and that has not seemed > to have broken anything. It also has the support of a 'standard', and > most (all?) of the commercial UNIX providers following it (anyone want to > try on HP-UX and OSF/Digital UNIX?). The change to make is *trivial*, in > the 'builtin' echo.c in sh you need to uncomment the line > "#define eflag 1" Just write your shell scripts portably; that way they will work on all platforms, back to Xenix 1.1.x, which didn't support shell functions. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message