[comp.unix.shell] Echo? What echo? Korn shell 88

FISH@LIVERPOOL.AC.UK (10/19/90)

I have recently discovered a problem with ksh88. The print command has a flag
-s that allows you to place things into the history file, i.e.

print -s Hello there

will place "Hello there" in the history file. The manual claims that echo
uses the echo program which means that echo -s should print the string -s.
For reasons explained below this is the preferred behaviour.
However, it would appear that echo has been aliased to print, even though the
manual would claim that this is not the case and echo is /bin/echo like in the
Bourne shell and earlier versions of the K shell.

Has anyone had this problem and how did you crack it?

alias -x echo /bin/echo dosen't work and gives an error

neither does defining a function although you can do this without an error
message.

Background:

I have been trying to write a simple training manual for users that has
a worked example that uses the flag -s. This is to show some of the
dangers in using test with things like [ -s = -s  ], which works in            n
some implementations and not others. Unfortunately the way round it I discuss
using `if echo $arg | grep -s -e -s' no longer works if echo -s dosen't send
-s to stdout. I don't want to use the [[ ]] construct because we don't have
ksh88 across the whole site, even though I recomend its use if available.

Thanks in advance. Any ideas?

Francis Fish
Programmer / Analyst
Liverpool University Computer Laboratory
fish@uk.ac.liverpool

gt0178a@prism.gatech.EDU (Jim Burns) (10/20/90)

in article <90292.140155FISH@LIVERPOOL.AC.UK>, FISH@LIVERPOOL.AC.UK says:

> alias -x echo /bin/echo dosen't work and gives an error

It will if you include the '=':

alias -x echo=/bin/echo
-- 
BURNS,JIM
Georgia Institute of Technology, Box 30178, Atlanta Georgia, 30332
uucp:	  ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt0178a
Internet: gt0178a@prism.gatech.edu

lml@cbnews.att.com (L. Mark Larsen) (10/21/90)

In article <90292.140155FISH@LIVERPOOL.AC.UK>, FISH@LIVERPOOL.AC.UK writes:
> I have recently discovered a problem with ksh88. The print command has a flag
> -s that allows you to place things into the history file, i.e.
> 
> print -s Hello there
> 
> will place "Hello there" in the history file. The manual claims that echo
> uses the echo program which means that echo -s should print the string -s.

I tried this with ksh86, ksh88, ksh88e and "echo -s" prints "-s".  Of course,
it is possible that your version of ksh was compiled to exclude echo - it
is an option afterall.  If so, there might be an alias (poorly defined) for it
in your environment.  Try "alias echo" or "whence -v echo" to see.  A proper
alias for echo (if needed) is:

	alias echo='print -'

The '-' ends the argument string for print so, with this alias, your attempt
to do "echo -s" will work as expected.  No need to call /bin/echo.

> Thanks in advance. Any ideas?
> 
> Francis Fish

L. Mark Larsen
lml@atlas.att.com