Date: Tue, 15 Sep 1998 22:36:49 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: crossd@cs.rpi.edu (David E. Cross) Cc: cracauer@cons.org, jmoss@ichips.intel.com, chet@po.cwru.edu, freebsd-current@FreeBSD.ORG Subject: Re: 'bug' in /bin/sh's builtin 'echo' Message-ID: <199809152236.PAA09100@usr06.primenet.com> In-Reply-To: <Pine.GSO.3.95.980915144632.24623B-100000@eggbeater.cs.rpi.edu> from "David E. Cross" at Sep 15, 98 02:52:11 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809152236.PAA09100>