Subject: Re: Answer to "which echo.c"
To: None <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: current-users
Date: 12/09/1999 14:33:43
> I expected the thread to digress into "but how do you just echo
> '-n'??" but recognize that this isn't very important.

Actually, it's important mainly for compatability.  If a script written
for BSD wants to echo something ending in the two characters "\c", it
breaks badly with a SV-compatible echo; similarly, a written-for-SV
script that tries to echo "-n" breaks with a BSD-compatible echo.

> - A few differences [...], except for the '\c' compatibility, which
> only one version supports.  WHY?  [...] it's easy to create
> compatibility in small utilities like this one, yet only one bsd out
> of three allowed SYSV scripts to not bug.

*None* of them works in a SysV-compatible way.  SysV "echo -n -i" will
produce six bytes of output, "-n -i" and a newline.  None of the
versions you quoted will do that.  And one of them breaks with BSD
compatability when handed a command-line ending with the two characters
"\c" (and doesn't even do the SysV-compatible thing wrt processing
other backslash escapes).

> Note that SYSV compatibility allows use of:
>       echo Yes or No? \c 
> which will not output newline.

Try it.  You need to write

	echo Yes or No\? \\c

or something else that quotes the ? and \.  (Some shells, such as sh,
won't need to quote the ? if "No?" doesn't glob to any files.)

					der Mouse

		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B