echo

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Dec 11 20:07:09 AEST 1988


In article <675 at auspex.UUCP>, guy at auspex.UUCP (Guy Harris) writes:
[I previously commented:]
> >What a botch this is!  Nobody I know of puts /usr/ucb before /usr/bin
> >even on native BSD systems.
> They don't have to; the default PATH on BSD systems is
> ":/usr/ucb:/bin:/usr/bin".

But this is so well-known to be idiotic that everyone I know of sets his
own PATH in his .profile.  In fact since our .profiles are used on a wide
variety of UNIX implementations, they generally include code like this:

NPATH=
for d in /usr/5bin /vld/bin $HOME/bin /bin /usr/bin /usr/sccs /.bin \
 /usr/.bin /usr/ucb /usr/bsd /etc /usr/etc /usr/mdqs/bin /usr/brl/bin \
 /usr/brlcad/bin /usr/brl/sbin /usr/local/bin /usr/local/eroff/bin /usr/lbin
do	if [ $d = /usr/local/bin -a ! -d $d ]
	then	d=/usr/local
	fi
	if [ -d $d ]
	then	NPATH=$NPATH$d:
	fi
done
if [ "$NPATH" ]
then	PATH=$NPATH.
	export PATH
else	echo '.profile: reverting to default $PATH' >&2
fi
unset NPATH

Even in a pure 4BSD environment, you will notice, I don't put /usr/ucb
ahead of /bin and /usr/bin.  There are several reasons for this, but the
main ones are improved average search speed (since very few useful utilities
are in /usr/ucb) and standard environment (since /usr/ucb/grep etc. are
usually brain-damaged).

> Shell scripts generally want to set PATH right after they've set IFS
> (unless your shell doesn't import IFS); I generally do so in my scripts
> these days.

Yes, and even 4BSD shell scripts normally include something like
	PATH=/bin:/usr/bin:/usr/ucb export PATH
(Again, getting the wrong version of "echo" under SVR4.0.)

> ... the rules will be "put '/usr/ucb' at the front if you expect
> BSD-style versions, and put it at the end or leave it out if you don't.

Unfortunately this reversal of the /usr/5bin approach doesn't work
right.  There should have been a separate /usr/bsdbin or such to
contain the BSD compatibility versions of utilities; /usr/ucb is
already in use WITH A DIFFERENT MEANING.

> "echo" is treated just like non-built-in commands in that sense (thanks
> and a tip of the Hatlo hat to Dave Korn for the idea); if the shell
> would have found the BSD-style version were it not built in, it makes it
> act like the BSD-style version, and if it would have found the S5-style
> version were it not built in, it makes it act like the S5-style version.

But as you can see, the problem with this approach is that it encourages
further delay in FIXING the broken System V "echo" behavior.  The BRL
Bourne shell can be configured to default either way, but in either
configuration it supports the 9th Edition UNIX -e and -n options.  (There
is no opposite of -e, although probably System V could use one today.)
This provides a transitional aid for people to fix the System V scripts to
use -e when they really intend for \-escapes to be interpreted.  However,
this transition will not occur until implementors start cooperating.

Instead of working to fix design errors via transition to better designs,
vendors seem to be accreting all the misfeatures ever used by anybody..



More information about the Comp.unix.wizards mailing list