Echo

Usenet Administration meissner at xyzzy.UUCP
Sun Dec 11 11:33:51 AEST 1988


In article <960 at etnibsd.UUCP> vsh at etnibsd.UUCP (Steve Harris) writes:
| FYI -- SunOS 3.x has done this brain damaged thing of looking to see
| which is first in your PATH variable: /usr/ucb or /usr/5bin.  The
| builtin echo (and, I believe, /bin/echo) will operate in either BSD or
| ATT mode depending on which directory comes first.
| 
| The problem is, what if I want /usr/ucb before /usr/5bin in my PATH,
| but also want my echo to recoginze sysV escapes?  I have to do, e.g.:
| 
| OPATH=$PATH
| $PATH=/usr/5bin:$PATH
| echo "\tthis is a test\n"
| PATH=$OPATH

While in general, I prefer not to hard code paths, in this case pragmatism
wins out.  On scripts where you need System V escape semantics (like scripts
that send control sequences to the terminal or windowing system), just hard
code the path.  If the script is only going to be run on Suns, just use
/usr/5bin/echo directly, and don't futz around with the PATH.  If your
script(s) need to be run on multiple systems, you could set an environment
variable, like I do (in /bin/sh notation):

	if [ -x /bin/sun3 ] && /bin/sun3; then
		SYSVECHO=/usr/5bin/echo
	else
		SYSVECHO=echo
	fi

	# ...

	${SYSVECHO} ...
-- 
Michael Meissner, Data General.

Uucp:	...!mcnc!rti!xyzzy!meissner
Arpa:	meissner at dg-rtp.DG.COM   (or) meissner%dg-rtp.DG.COM at relay.cs.net



More information about the Comp.unix.wizards mailing list